问题描述
在角JS 2.0,你怎么清除模板缓存?有吨的角JS 1.0的答案,但没有2.0。
我遇到的问题是,当我改变由templateUrl上的任何组件所引用的html页面的内容,HTML页面不会在浏览器中改变,直到我手动导航到templateUrl在浏览器和命中重装。我知道你可以禁用浏览器的缓存在开发过程中来解决这个问题,但我担心的是,用户可以看到一个过时的HTML页面,如果他们已经在他们的浏览器缓存,当我去更新的角度JS 2.0网站。
下面是对角JS 1.0堆栈溢出问题的链接
AngularJS在开发机关闭部分缓存
下面是一个片段,当其含量改变我有app.html更新的相关问题。
@Component({
选择:照相馆应用,
templateUrl:./app/app.html',
指令:[ROUTER_DIRECTIVES,CORE_DIRECTIVES]
})
在流问题下面的堆栈提供了通过附加一个版本参数的URL解决这个问题的一个大战略。
这在理论上应该为产品发布工作的伟大。然后进行开发,我可以简单的禁用浏览器的缓存。
In Angular JS 2.0, how do you clear the template cache? There are tons of answers for Angular JS 1.0, but none for 2.0.
The issue I am having is that when I change the contents of the html pages referenced by templateUrl on any components, the html pages don't change in the browser until I manually navigate to the templateUrl in the browser and hit reload. I know you can disable the browser cache to solve this during development, but my concern is that users can see an outdated html page if they have it cached in their browser when I go to update a website with angular JS 2.0.
Here is a link to the stack overflow questions for Angular JS 1.0AngularJS disable partial caching on dev machine
Below is a snippet and I am having issues with app.html updating when its content is changed.
@Component({
selector: 'photogallery-app',
templateUrl: './app/app.html',
directives: [ROUTER_DIRECTIVES, CORE_DIRECTIVES]
})
The following stack over flow question provides a great strategy for solving this problem by appending a version parameter to the Url.
This in theory should work great for production releases. Then for development, I can simple disable the browser cache.
这篇关于如何清除模板缓存 - 角JS 2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!