使用HashLocationStrategy

时间:2016-06-21 18:18:53

标签: angular angular2-routing angular2-template

遇到angular2和HashLocationStrategy的一个有趣问题。我在我的hashlocationstrategy中实现了boot.ts,如此:

provide(LocationStrategy, {useClass: HashLocationStrategy}),

现在我的网址中包含#,这很好。现在,当我刷新它时,不再有404错误,但在重新加载index.html时出现了不同的错误。发生的事情是我写的属性服务没有在刷新时正确填充我的应用程序属性。它工作得很好但是如果我打开chrome开发人员工具并勾选“禁用缓存”复选框。如果我只是清除我的缓存然后刷新,也可以工作。似乎这些属性在使用HachLocationStrategy刷新时被清除,但缓存认为它们仍然存在。因此,当我的应用程序再次加载index.html时,我收到一个错误,该属性为null并且会出现各种错误,如:

TypeError: Cannot read property 'logGroup' of null(…)

有没有办法在刷新时强制清除浏览器缓存?我在index.html中添加了一些元标记,例如:

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">

当我尝试让RunTimeCompiler清除模板缓存时,我得到一个错误,它无法找到该类。接受任何建议。

0 个答案:

没有答案
相关问题