我试图通过将 $compileProvider.debugInfoEnabled(false);
放入 angular.config()
来禁用调试信息。但是为什么当我在chrome浏览器中check in时,我仍然可以看到带有angular watchers
插件的观察者数量。感觉调试信息没有被禁用。
如何禁用它?
我的工作代码示例:
angular.module('app.core.config', [])
.config(['$compileProvider', function ($compileProvider) {
// disable debug info
$compileProvider.debugInfoEnabled(false);
}]);
最佳答案
这是因为 Ionic overrides the default behavior :
/**
* @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;
}]);
}]);
如果您注入(inject) $compile
服务,您可以检查它并看到 $$addScopeInfo
不是 noop 函数,因为它通常是在调试信息被禁用时:
$$addBindingClass: noop()
$$addBindingInfo: noop()
$$addScopeClass: noop()
$$addScopeInfo: $$addScopeInfo($element, scope, isolated, noTemplate)
关于angularjs - Angular 禁用 debugInfoEnabled,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34148116/