浏览器未检测到 AngularJS 中的更改
Browser does not detect changes in AngularJS
我正在使用 IDE WebStorm 和 Safari 浏览器开发 AngularJS 应用程序。
到目前为止一切都运行良好,但我最近将一些 HTLM 封装在我通过指令使用的模板中:
.directive('referenceValue', [function ($scope) {
return {
restrict: 'E',
templateUrl: "views/citizenprofile/reference/reference.html",
controller: "referenceValueCtrl"
}
}])
我 "call" 以正常方式执行指令,没什么特别的 <reference-value></reference-value>
当我编辑 reference.html 时,浏览器仅检测到 第一次编辑中的更改。。如果我第二次编辑 reference.html 并更新浏览器,则不会检测到更改。如果我重新启动浏览器,则会再次检测到更改。所以每次我想调试 HTML 代码时,我基本上都需要重新启动浏览器。
每次编辑时都会检测到 Controller 中的更改。
谁能告诉我如何解决这个错误?
如果您使用的是 google chrome,请按 CTRL+SHIFT+J 并在网络选项卡上选中 'Disable Cache'
希望对您有所帮助
正在缓存您的模板。有几个解决方法。在开发工具打开时使用 Chrome 的开发工具禁用缓存,或者在您的应用程序中使用 $templateCache.remove()
。
app.run(function($rootScope, $templateCache) {
$rootScope.$on('$viewContentLoaded', function() {
$templateCache.removeAll();
});
});
查找有关删除模板缓存的更多信息here。
我正在使用 IDE WebStorm 和 Safari 浏览器开发 AngularJS 应用程序。
到目前为止一切都运行良好,但我最近将一些 HTLM 封装在我通过指令使用的模板中:
.directive('referenceValue', [function ($scope) {
return {
restrict: 'E',
templateUrl: "views/citizenprofile/reference/reference.html",
controller: "referenceValueCtrl"
}
}])
我 "call" 以正常方式执行指令,没什么特别的 <reference-value></reference-value>
当我编辑 reference.html 时,浏览器仅检测到 第一次编辑中的更改。。如果我第二次编辑 reference.html 并更新浏览器,则不会检测到更改。如果我重新启动浏览器,则会再次检测到更改。所以每次我想调试 HTML 代码时,我基本上都需要重新启动浏览器。 每次编辑时都会检测到 Controller 中的更改。
谁能告诉我如何解决这个错误?
如果您使用的是 google chrome,请按 CTRL+SHIFT+J 并在网络选项卡上选中 'Disable Cache'
希望对您有所帮助
正在缓存您的模板。有几个解决方法。在开发工具打开时使用 Chrome 的开发工具禁用缓存,或者在您的应用程序中使用 $templateCache.remove()
。
app.run(function($rootScope, $templateCache) {
$rootScope.$on('$viewContentLoaded', function() {
$templateCache.removeAll();
});
});
查找有关删除模板缓存的更多信息here。