Skip to content

Instantly share code, notes, and snippets.

@cjmamo
Last active March 15, 2017 11:29
Show Gist options
  • Save cjmamo/9092047 to your computer and use it in GitHub Desktop.
Save cjmamo/9092047 to your computer and use it in GitHub Desktop.
Safely Prevent Template Caching in AngularJS
...
app.run(function($rootScope, $templateCache) {
$rootScope.$on('$viewContentLoaded', function() {
$templateCache.removeAll();
});
});
...
app.run(function($rootScope, $templateCache) {
$rootScope.$on('$routeChangeStart', function(event, next, current) {
if (typeof(current) !== 'undefined'){
$templateCache.remove(current.templateUrl);
}
});
});
@hemantasapkota
Copy link

Fixed my problem. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment