要胀爆的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开发之路
人一旦上了年纪,记忆力就变得越来越不好. 最近写了许多的博文,倒不是为了给谁看,而是方便自己来搜索,不然一下子又忘记了. 如果恰巧帮助到了你,也是我的荣幸~~~~~~~~~~~~ 废话不多说,看正题~ ...
随机推荐
- 在VisualStudio 工具箱中隐藏用户控件
当我们创建一个用户控件后,VisualStudio会自动将其添加到工具箱中,本来这是一个比较贴心的设计.但是,有的时候,我们并不想将用户控件放到工具箱中. 例如:在WPF中,为了避免一个页面的控件过多 ...
- IdHTTPServer(indy10)开发REST中间件
IdHTTPServer(indy10)开发REST中间件 浏览器通过“get”方式查询数据URL样例:http://127.0.0.1:7777/query?sql=select * from t1 ...
- form的action属性作用
一.action=""和action="#".没有action属性的作用相同,都是提交到当前页面(也就是document.location.href) 二.ac ...
- 专业术语:闭包、网站优化 Gzip 服务器端文件压缩
1, 闭包:http://baike.baidu.com/view/648413.htm 2, 网站优化 Gzip 服务器端文件压缩 http://baike.baidu.com/view/96662 ...
- wp8使用mvvm模式简单例子(二)---登陆功能,事件触发
首先,还是需要一个Model类来为UI层的元素提供数据源 public class LoginModel:DependencyObject { public string Uid { get { re ...
- iOS_block代码块
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcHJlX2VtaW5lbnQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQk ...
- SQL语句练习手册--第四篇
一.变量那点事儿 1.1 局部变量 (1)声明局部变量 DECLARE @变量名 数据类型 ) DECLARE @id int (2)为变量赋值 SET @变量名 =值 --set用于普通的赋值 SE ...
- linux生成指定大小的文件(转)
# dd if=/dev/zero of=50M.file bs=1M count=50在当前目录下生成一个50M的文件 虚拟块设备文件更通用的名称是硬盘镜像文件(Hard Disk Image),但 ...
- apue学习笔记(第一章UNIX基础知识)
总所周知,UNIX环境高级编程是一本很经典的书,之前我粗略的看了一遍,感觉理解得不够深入. 听说写博客可以提高自己的水平,因此趁着这个机会我想把它重新看一遍,并把每一章的笔记写在博客里面. 我学习的时 ...
- delphi的字节对齐
如果不改编译选项Delphi的Record默认也是4字节对齐的. 可以用编译开关指定 {$A4+}就是4字节对齐.同理{$A2+}.{$A1+}等.{$A1+}等同于Packed Record 主要容 ...