【问题标题】:Do you need to deregister scope watches when scope is destroyed?作用域被销毁时是否需要注销作用域监视?
【发布时间】:2014-05-21 13:56:20
【问题描述】:

假设您创建了一个本地范围,然后调用$scope.$watch()$scope.$on()。当本地作用域被销毁时,是否需要通过调用$watch$on返回的注销方法来注销它们,或者它们会自动注册?

我正在尝试清理一些内存泄漏,这看起来可能是其中之一。当然,文档对此并不十分清楚。

【问题讨论】:

    标签: javascript angularjs angularjs-scope


    【解决方案1】:

    Watchers 和 listeners 将被自动清理。两者都保存为它们注册的范围的属性:$$watchers 中的watchers$$listeners 中的listeners

    【讨论】:

      猜你喜欢
      • 2014-01-09
      • 2016-04-19
      • 1970-01-01
      • 2015-09-06
      • 2016-07-16
      • 2011-02-23
      • 2011-07-01
      • 2014-04-02
      • 2021-06-15
      相关资源
      最近更新 更多