AngularJS’s $templateCache can be a pain in the ass. Sometimes we don’t want templates to be cached. With the UI Bootsrap module, a solution is to remove new cache entries on route change instead of indiscriminately removing all entries:
app.run(function($rootScope, $templateCache) { $rootScope.$on('$routeChangeStart', function(event, next, current) { if (typeof(current) !== 'undefined'){ $templateCache.remove(current.templateUrl); } }); });
Leave a Reply