浏览器不会检测AngularJS中的更改

时间:2015-10-09 14:23:14

标签: angularjs angularjs-directive angular-controller

我正在使用IDE WebStorm和Safari浏览器开发AngularJS应用程序。

到目前为止,一切都运行良好,但我最近在一个模板中封装了一些HTLM,我通过一个指令使用:

 .directive('referenceValue', [function ($scope) {
    return {
        restrict: 'E',
        templateUrl: "views/citizenprofile/reference/reference.html",
        controller: "referenceValueCtrl"
    }
}])

我&#34;打电话&#34;指令是正常的方式,没什么花哨的<reference-value></reference-value>

当我编辑reference.html时,浏览器只检测第一次修改中的更改。。如果我第二次编辑reference.html并更新浏览器,则不会检测到更改。如果我重新启动浏览器,则会再次检测到更改。因此,每次我想调试HTML代码时,我基本上都需要重新启动浏览器。 每次编辑时都会检测到控制器中的更改。

有谁能告诉我如何修复此错误?

1 个答案:

答案 0 :(得分:1)

正在缓存您的模板。有几个工作。使用Chrome的开发工具在开发工具打开时禁用缓存,或者在应用程序中使用$templateCache.remove()

app.run(function($rootScope, $templateCache) {
   $rootScope.$on('$viewContentLoaded', function() {
      $templateCache.removeAll();
   });
});

查找有关删除模板缓存here的更多信息。

相关问题