浏览器未检测到AngularJS中的更改 [英] Browser does not detect changes in AngularJS

查看:80
本文介绍了浏览器未检测到AngularJS中的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Im developing an AngularJS application using IDE WebStorm and Safari browser.

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

Everything has worked perfectly so far, but I recently encapsulated some HTLM in a template that I use via a directive:

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

我以正常方式调用"该指令,没有幻想<reference-value></reference-value>

I "call" the directive the normal way, nothing fancy <reference-value></reference-value>

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

When I edit the reference.html the browser only detects the changes in the first edit.. If I edit reference.html a second time and update the browser then the change is not detected. If I restart the browser the change is detected again. So I basically need to restart my browser each time I want to debug the HTML code. Changes in the Controller is detected at every edit.

有人可以告诉我如何解决此错误吗?

Can anyone tell me how to fix this error?

推荐答案

正在缓存您的模板.有一些解决方法.打开开发工具时,可以使用Chrome的开发工具禁用缓存,也可以在应用程序中使用$templateCache.remove().

Your template is being cached. There are a couple of work arounds. Either use Chrome's dev tools to disable cache when the dev tools is open, or use the $templateCache.remove() in your application.

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

查找有关删除模板缓存的更多信息这里.

Find more info on removing the template cache here.

这篇关于浏览器未检测到AngularJS中的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆