要胀爆的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开发之路
人一旦上了年纪,记忆力就变得越来越不好. 最近写了许多的博文,倒不是为了给谁看,而是方便自己来搜索,不然一下子又忘记了. 如果恰巧帮助到了你,也是我的荣幸~~~~~~~~~~~~ 废话不多说,看正题~ ...
随机推荐
- 在Ubuntu Server 中安装图形用户界面
使用ubuntu server安装lamp主机非常的方便,只要在安装系统的步骤中选择就是了 .但是很多时候我需要在图形界面下管理主机更加方便.今天的教程就是教大家安装图形界面. 首先你需要确定你的源文 ...
- CM3大礼包
- [置顶]
kubernetes资源类型--pod和job
pod Pod是K8S的最小操作单元,一个Pod可以由一个或多个容器组成:整个K8S系统都是围绕着Pod展开的,比如如何部署运行Pod.如何保证Pod的数量.如何访问Pod等. 特点 Pod是能够被创 ...
- ISP模块之RAW DATA去噪(一)
ISP(Image Signal Processor),图像信号处理器,主要用来对前端图像传感器输出信号处理的单元,主要用于手机,监控摄像头等设备上. RAW DATA,可以理解为:RAW图像就是CM ...
- python读写文件write和flush
打开文件用open,该函数创建一个文件对象,这将用来调用与之关联的其他支持方式. file object = open(file_name [, access_mode][, buffering]) ...
- ssh免密码登录之分发密钥
ssh免密码登录之分发密钥 1.ssh免密码登录 密码登录和密钥登录有什么不同? 密码登录(口令登录),每次登录都需要发送密码(ssh) 密钥登录,分为公钥和私钥,公钥相当于锁,私钥相当于钥匙 1.1 ...
- 2017.7.12 IDEA热部署(更新jsp或java代码不用重启tomcat即可即时生效)
选择war explored. 主要在于 On frame deactivation选项配置选择为 Update classes and resourses(当且仅当在Deployment配置页,对应 ...
- Resin服务器部署web项目
Resin服务器部署web项目 学习了:https://blog.csdn.net/eff666/article/details/53324167 需要配置resin.xml文件: <host ...
- Material Design (二),TextInputLayout的使用
前言 一般登录注冊界面都须要EditText这个控件来让用户输入信息,同一时候我们通常会设置一个标签(使用TextView)和EditText的hint属性来提示用户输入的内容,而设计库中高级组件T ...
- JAVA_Exception starting filter struts2怎么办
1 请确保你的项目里面有这两个文件,没有则导入 2 如果还不行,并且你设置了Struts的开发模式,并且你的Tomcat的路径有空格,大部分情况是Program File的原因,此时你需要重新安装 ...