要胀爆的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开发之路
人一旦上了年纪,记忆力就变得越来越不好. 最近写了许多的博文,倒不是为了给谁看,而是方便自己来搜索,不然一下子又忘记了. 如果恰巧帮助到了你,也是我的荣幸~~~~~~~~~~~~ 废话不多说,看正题~ ...
随机推荐
- centos下配置ssh使用密钥
查询了网上的一些教程,然后根据自己的实际操作,记录自己实际配置ssh密钥的过程: 首先在centos终端切换到要链接的用户,比如用户ssh 使用该用户生成密钥: ssh-keygen -t rsa 中 ...
- Linux的五个查找命令:find,locate,whereis,which,type 及其区别
1. find find是最常见和最强大的查找命令,你可以用它找到任何你想找的文件. find的使用格式如下: $ find <指定目录> <指定条件> <指定动作> ...
- IOS设置UIView的边框为圆角
iOS 系统自带的 View 组件都是正方形的,看起来都太生硬,有时候我需要变成圆角形式,如下图: 具体的实现是使用QuartzCore库,下面我具体的描述一下实现过程: • 首先 ...
- JAVA常见算法题(十六)
package com.xiaowu.demo; //猴子吃桃问题:猴子第一天摘下若干个桃子,当即吃了一半,还不过瘾,又多吃了一个: //第二天早上又将剩下的桃子吃掉一半,而且又多吃了一个. //以后 ...
- 鸟哥的linux私房菜学习记录之计算机概论
- textureView
textureView是用来访问texture的一部分的 cubemap 和 mipmap会用到这个 for(face =0;face<6;face++) setrendertarget(tex ...
- linux下eclipse闪退和重装jdk的方法
安装eclipse: (1)把eclipse-java-helios-SR2-linux-gtk.tar.gz解压到某个目录中,我解压到的 是/usr/eclipse,得到eclipse目录 (2)在 ...
- 2017.6.30 用shiro实现并发登录人数控制(实际项目中的实现)
之前的学习总结:http://www.cnblogs.com/lyh421/p/6698871.html 1.kickout功能描述 如果将配置文件中的kickout设置为true,则在另处再次登录时 ...
- 2017.5.27 使用propagation实现:根据参数决定是否需要事务管理
1.功能描述 要实现rest接口:POST ***/entry,其中参数中有action参数. 当action=rollback时,批量新增出错时需要回滚. 当action!=rollback时,批量 ...
- ACdreamoj 1011(树状数组维护字符串hash前缀和)
题目链接:http://acdream.info/problem? pid=1019 题意:两种操作,第一种将字符串某个位置的字符换为还有一个字符.另外一种查询某个连续子序列是否是回文串: 解法:有两 ...