I am here to discus my problem with my AngularJS project. currently everything is working. Getting response from APIs and setting data from API. but sometimes it get 400 error due to cache. after removing cache again works fine. So I want to build a code for when I refresh page cache should be removed. I tried $templateCache but not working anymore.
-
What makes you think those responses were cached?user149341– user1493412016-11-30 06:37:51 +00:00Commented Nov 30, 2016 at 6:37
-
I am using a chrome extension ( Clear All Cache ) to one click remove caceh. after clearing cache and refreshing page. its working fine.AWE– AWE2016-11-30 06:42:46 +00:00Commented Nov 30, 2016 at 6:42
Add a comment
|
2 Answers
try this
app.run(function($rootScope, $templateCache) {
$rootScope.$on('$routeChangeStart', function(event, next, current) {
if (typeof(current) !== 'undefined'){
$templateCache.remove(current.templateUrl);
}
});
});
1 Comment
staminna
I know it is old thread but can you ellaborate? I went ahead and tried in my ng-controller.js file but either it worked and I couldn't tell it was working, or it didn't. Where should I be looking at? Thanks in advance!