简体   繁体   中英

How to clear template cache in angularjs

In Angularjs, I have made many html pages for the project.But in one browser the html pages comes from cache so that I can't get new changes in that browser(doing refresh and hard refresh).

Sometime I get new changes in html after hard refresh the page and sometime I didn't get it.

Please give me some solution for it.

My sample for caching:-

mainApp.run(['$rootScope','$cacheFactory', function($rootScope,$cacheFactory) {
$cacheFactory.get('$http').removeAll()
.....
....
}

If you want to remove cached views from the code.

app.run(function($rootScope, $templateCache) {
    $rootScope.$on('$routeChangeStart', function(event, next, current) {
        if (typeof(current) !== 'undefined'){
            $templateCache.remove(current.templateUrl);
        }
    });
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM