2

Is there any way to disable template cache in Angular 2 ?

I'm creating one single page application in Angular2.My App have three page. So i use Route to switch from one page to another.In one of my page i have a submit button.I need to disable it based on values selected by user. My issue is that Once i make it disabled it will remain disabled until i refresh the page.It will not enable when i go back to come to same page. This is because of Template caching . Html page is not reloading once it loaded.

Is there any way to disable cache or reload template ?

Thanks

DAN
  • 2,630
  • 5
  • 14
  • 22

2 Answers2

0

Issue is fixed now. Caching is occurred due to angular 2 beta.0 version. Now I updated it to beta.13. It's working now.

DAN
  • 2,630
  • 5
  • 14
  • 22
-3

Please try the following links that address your question:

AngularJS disable partial caching on dev machine

How to clear template cache

Alternatively you can try this code:

...

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

Hope it helps!

Community
  • 1
  • 1
user2090166
  • 115
  • 1
  • 1
  • 10