Reputation: 645
Hello I have small probelm: How do you clear the cache after you load a view in ui-router in AngularJS. Please help me
Upvotes: 1
Views: 1051
Reputation: 445
app.controller('mainController', function($scope,$templateCache,$rootScope){
$scope.btnUpdate = function(){
$rootScope.$on('$viewContentLoaded', function() {
$templateCache.removeAll();
});
}
});
Upvotes: 0
Reputation: 222522
Try this,
app.run(function($rootScope, $templateCache) {
$rootScope.$on('$routeChangeStart', function(event, next, current) {
if (typeof(current) !== 'undefined'){
$templateCache.remove(current.templateUrl);
}
});
});
Upvotes: 1