角度禁用 debugInfoEnabled

use*_*781 3 angularjs ionic-framework

我试图通过放入 来禁用调试$compileProvider.debugInfoEnabled(false);信息angular.config()。但是为什么我在chrome浏览器中查看时,仍然可以看到有angular watchers插件的观看人数。感觉调试信息没有被禁用。

我怎样才能禁用它?

我的工作代码示例:

angular.module('app.core.config', [])
.config(['$compileProvider', function ($compileProvider) {
    // disable debug info
    $compileProvider.debugInfoEnabled(false);
}]);
Run Code Online (Sandbox Code Playgroud)

tas*_*ATT 5

这是因为 Ionic覆盖了默认行为

/**
 * @private
 * Parts of Ionic requires that $scope data is attached to the element.
 * We do not want to disable adding $scope data to the $element when
 * $compileProvider.debugInfoEnabled(false) is used.
 */
IonicModule.config(['$provide', function($provide) {
  $provide.decorator('$compile', ['$delegate', function($compile) {
     $compile.$$addScopeInfo = function $$addScopeInfo($element, scope, isolated, noTemplate) {
       var dataName = isolated ? (noTemplate ? '$isolateScopeNoTemplate' : '$isolateScope') : '$scope';
       $element.data(dataName, scope);
     };
     return $compile;
  }]);
}]);
Run Code Online (Sandbox Code Playgroud)

如果您注入$compile服务,您可以检查它并发现它$$addScopeInfo不是 noop 函数,因为它通常是禁用调试信息时的函数:

$$addBindingClass: noop()
$$addBindingInfo: noop()
$$addScopeClass: noop()
$$addScopeInfo: $$addScopeInfo($element, scope, isolated, noTemplate)
Run Code Online (Sandbox Code Playgroud)