要胀爆的Angular1.0
尝试从http请求上遏制缓存:
http://blog.csdn.net/u010039979/article/details/54376856
if (!$httpProvider.defaults.headers.get) {
$httpProvider.defaults.headers.get = {};
}
//或者可以写成
$httpProvider.defaults.headers.get = $httpProvider.defaults.headers.get || {};
$httpProvider.defaults.headers.get['If-Modified-Since'] = 'Mon, 26 Jul 1997 05:00:00 GMT';
$httpProvider.defaults.headers.common['X-Requested-with'] = 'XMLHttpRequest';
$httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache';
$httpProvider.defaults.headers.get['Pragma'] = 'no-cache';
想要适当缓存:http://www.cnblogs.com/jiuyuehe/p/5238622.html
(function () {
'use strict';
var AppController = function ($scope, $rootScope, TranslateService) {
// Set page title on each page
this.listener = $scope.$on('$routeChangeSuccess', function (e, nextRoute) {
if (nextRoute.$$route && angular.isDefined(nextRoute.$$route.pageTitle)) {
$scope.pageTitle = nextRoute.$$route.pageTitle + ' | Bosch Warranty Process';
}
});
// when account data changes, set language that needs to be used
this.watcher = $rootScope.$watch('account', function () {
if (typeof $rootScope.account != 'undefined' && typeof $rootScope.account.language != 'undefined') {
TranslateService.changeLanguage($rootScope.account.language);
} else {
TranslateService.setDefaultLanguage();
}
});
$scope.$on("$destroy",function(){
AppController.listener();
AppController.listener = null;
$scope.$destroy();
});
$rootScope.$on("$destroy",function(){
AppController.watcher();
AppController.watcher = null;
$rootScope.$destroy();
$rootScope.$digest();
});
};
AppController.$inject = ['$scope', '$rootScope', 'TranslateService'];
angular
.module('warrantyProcessApp')
.controller('AppController', AppController);
})();
清除rooteScope:
- it('should ignore remove on root', inject(function($rootScope) {
+ it('should broadcast $destroy on rootScope', inject(function($rootScope) {
+ var spy = spyOn(angular, 'noop');
+ $rootScope.$on('$destroy', angular.noop);
$rootScope.$destroy();
$rootScope.$digest();
expect(log).toEqual('');
+ expect(spy).toHaveBeenCalled();
+ expect($rootScope.$$destroyed).toBe(true);
}));
https://github.com/angular/angular.js/commit/d802ed1b3680cfc1751777fac465b92ee29944dc
关于$digest();
理解Angular中的$apply()以及$digest()
清除scope:
var offDestroy = $scope.$on('$destroy', function() {
scope.$destroy();
});
scope.$on('$destroy', offDestroy);
清除scope监听的事件http://liyunpeng.iteye.com/blog/2257154
另外闭包什么的就麻烦了:
http://www.cnblogs.com/carekee/articles/1733847.html
语法错集锦:
Error: [$compile:ctreq] Controller 'ngModel', required by directive 'ngChange', can't be found!
提示:有ng-change的标签却没有ng-module
解决方法:在input上加上ng-model属性,例如你要获取input里面的值,在controller中定义: $scope.aValue = '', 然后模板中 <input ng-model='aValue' ng-change='mychange()' />
要胀爆的Angular1.0的更多相关文章
- webpack前端构建angular1.0!!!
webpack前端构建angular1.0 Webpack最近很热,用webapcak构建react,vue,angular2.0的文章很多,但是webpack构建angualr1.0的文章找来找去也 ...
- angular1.0 app
angular 1.0 简单的说一下就是ng启动阶段是 config-->run-->compile/link config阶段是给了ng上下文一个针对constant与provider修 ...
- UVa 10382 - Watering Grass 贪心,水题,爆int 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- Angular1.0
公司会议室组织分享,两个小时困死我了,一点凌乱笔记: $http.get和promise一样有then方法,成功,失败 jquery each遍历对象i,n ng-app ng-controller ...
- Angular1.0 在Directive中调用Controller的方法
Controller中定义了$scope.method = function(){} Directive中需要引入$scope http://stackoverflow.com/questions/2 ...
- Angular1.0路由的Hashbang和HTML5模式
原文答主jupiter http://stackoverflow.com/questions/16677528/location-switching-between-html5-and-hashban ...
- angular1.0 $http jsonp callback
$http.jsonp(sDUrl,{cache:false,jsonpCallbackParam:'callback'}); https://stackoverflow.com/questions/ ...
- angularjs 2.0 快速案例(1)
前言 上一节我们已经把环境给搭建起来了,现在我们通过一个快速案例把angular 2.0 初步了解一下,后续我们会深入每一个细节,这个案例主要是一个[英雄(Hero)]列表的展示,创建,编辑.这个案例 ...
- Webstorm 下的Angular2.0开发之路
人一旦上了年纪,记忆力就变得越来越不好. 最近写了许多的博文,倒不是为了给谁看,而是方便自己来搜索,不然一下子又忘记了. 如果恰巧帮助到了你,也是我的荣幸~~~~~~~~~~~~ 废话不多说,看正题~ ...
随机推荐
- Winform打砖块游戏制作step by step第4节---小球移动
一 引子 为了让更多的编程初学者,轻松愉快地掌握面向对象的思考方法,对象继承和多态的妙用,故推出此系列随笔,还望大家多多支持. 预备知识,无GDI画图基础的童鞋请先阅读一篇文章让你彻底弄懂WinFor ...
- Winform打砖块游戏制作step by step第三节---移动挡板
一 引子 为了让更多的编程初学者,轻松愉快地掌握面向对象的思考方法,对象继承和多态的妙用,故推出此系列随笔,还望大家多多支持. 预备知识,无GDI画图基础的童鞋请先阅读一篇文章让你彻底弄懂WinFor ...
- Delphi Modbus RTU CRC16校验码
function CheckCrc16(const ABuf; ALen: Integer): Boolean;var uwTemp: WORD; i, j: BYTE; P: PByte;begin ...
- 前端福利:一套UI框架
阅读目录 背景 预览效果 表单组件 普通文本框 多行文本框 复选框 切换滑块 单选框 下拉选择框 数字输入框 时间选择 文件选择 显示文本 按钮 开源地址 背景 目前市场上有很多表单美化的UI,做的都 ...
- MTD
内存技术设备(英语:Memory Technology Device,缩写为 MTD),是Linux系统中设备文件系统的一个类别,主要用于快闪存储器的应用,是一种快闪存储器转换层(Flash Tran ...
- GoodSync
文件管理这件看 似简单的事,真的不简单,因为为了防止意外情况,你需要对文件进行备份,时间一久随着文件数量的增加,再加上有时也会临时队备份文件进行修改等.再想查出 这个是最新的.文件有木有全部备份等…. ...
- mysql修改表字段属性类型
例如: 修改表expert_info中的字段birth,允许其为空 >alter table expert_info change birth birth varchar(20) null; 例 ...
- 修改oracle内存大小
在默认安装情况下,oracle的内存分配是按系统内存的大小比例分配的,内存比较大的情况下,oracle所占的内存也大,该情况下,我们一般要修改sga值来减少系统中oracle的内存过大问题. 用dba ...
- Java过滤器(Filter)与SpringMVC拦截器(Interceptor)之间的关系与区别
过滤器和拦截器的区别: ①拦截器是基于java的反射机制的,而过滤器是基于函数回调. ②拦截器不依赖与servlet容器,过滤器依赖与servlet容器. ③拦截器只能对action请求起作用,而过滤 ...
- 容量测试之tcpcopy引流模式
tcpcopy 给用户提供了很多命令参数来修改引流的模式和设置,详细可以查阅手册.在这里把几种常见的引流方式做个归纳小结,以tcpcopy传统架构使用命令举例. 1.分布式引流 用法:Tcpcopy可 ...