How to clear template cache?

后端 未结 9 1402
無奈伤痛
無奈伤痛 2020-11-27 18:04

In Angular 2, how do you clear the template cache? There are tons of answers for Angular 1, but none for 2.

The issue I am having is that when I change the contents

9条回答
  •  难免孤独
    2020-11-27 18:34

    I had a similar question. As a quick hack, i've solved this by introducing a global var in a module like export var fileVersion = '?tmplv=' + Date.now(); - at development time and change it for production - and use it in components like:

    @Component({
        selector: 'my-component',
        templateUrl: '/app/templates/my-component.html' + fileVersion,
    })
    

    So I have just to refresh the browser to see the changes. In production use export var fileVersion = '?tmplv=v1.3.7yourVersionNumber';.

提交回复
热议问题