一、清除模板缓存
.run(function($rootScope, $templateCache) {
$rootScope.$on('$routeChangeStart', function(event, next, current) {
if (typeof(current) !== 'undefined'){
$templateCache.remove(current.templateUrl);
}
});
});
二、html添加随机参数
.state("content", {
url: "/",
views:{
"bodyInfo":{templateUrl: 'tpls/bodyInfo.html?'+ +new Date(),
controller:'bodyInfoCtrl'},
"header":{templateUrl: 'tpls/header.html?'+ +new Date(),
controller:'headerCtrl'
},
"footer":{templateUrl: 'tpls/footer.html?'+ +new Date(),
controller:'footerCtrl'
}
}
})
三、清除route缓存
.config(['$stateProvider', '$urlRouterProvider','$locationProvider','$httpProvider',function($stateProvider, $urlRouterProvider,$locationProvider,$httpProvider) {
// $urlRouterProvider.when("", "/home");
$urlRouterProvider.otherwise('/');
if (!$httpProvider.defaults.headers.get) {
$httpProvider.defaults.headers.get = {};
}
$httpProvider.defaults.headers.common["X-Requested-With"] = 'XMLHttpRequest';
$httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache';
$httpProvider.defaults.headers.get['Pragma'] = 'no-cache';