【问题标题】:Once I turn off debuggingData in angular, is there another way to get the rootscope?一旦我关闭了角度的debuggingData,还有另一种获取rootscope的方法吗?
【发布时间】:2015-08-25 17:30:48
【问题描述】:

我认为在 Angular 中默认启用调试信息会使大型应用程序陷入困境。您现在可以在生产环境中禁用它:

https://docs.angularjs.org/guide/production#disabling-debug-data

但在某些情况下我会这样做:

angular.element(document).scope()

为了访问rootScope。在没有此调试功能的情况下,是否有另一种角度获取 $rootScope 的方法?

【问题讨论】:

  • 请引用链接目标中的相关部分,以防链接失效。谢谢!

标签: angularjs debugging angularjs-injector


【解决方案1】:

要访问$rootScope,您可以这样做

angular.element(document).injector().get('$rootScope')

【讨论】:

  • 太棒了。现在我可以点击 injector() 来获取 rootScope 而不是使用调试的东西。转动 $compileProvider.debugInfoEnabled(false);真的应该加快速度!
  • @httpete 很高兴为您提供帮助..谢谢 :)
猜你喜欢
  • 2019-04-25
  • 2020-08-23
  • 1970-01-01
  • 2022-12-24
  • 2017-09-09
  • 1970-01-01
  • 2012-10-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多