debugInfoEnabled for Angular 1.2

痞子三分冷 提交于 2019-12-03 11:27:00

Use the underlying DOM setAttribute method to prevent the default behavior. I've edited the plunker in the other answer:

http://plnkr.co/edit/cMar0d9IbalFxDA6AU3e?p=preview

to do the following:

  • Clone the DOM setAttribute prototype method
  • Override it with a check for ng debug attributes
  • Return false for ng debug attributes
  • Return as normal otherwise

Use it as follows:

/* Clone the original */
HTMLElement.prototype.ngSetAttribute = HTMLElement.prototype.setAttribute;

/* Override the API */
HTMLElement.prototype.setAttribute = function(foo, bar) {
/* Define ng attributes */ 
var nglist = {"ng-binding": true, "ng-scope":true,"ng-class":true,"ng-isolated-scope":true};

console.log([foo,bar]);

/* Block ng attributes; otherwise call the clone */
if (nglist[foo]) 
  return false; 
else if (JSON.stringify(nglist).match(foo) )
  return false;
else
  return this.ngSetAttribute(foo, bar);
}

Replace HTMLElement with Element for IE8.

References

Pankaj Parkar

You can try disable it by mentioning $logProvider.debugEnabled(true); inside your angular configuration. In order to get effect of debugEnabled setting, You need ensure that while doing log use $log provider.

Sample Code

var app = angular.module('myApp', []);

app.config(function($logProvider){
  $logProvider.debugEnabled(false);
});

app.controller('MainCtrl', function($scope, $log ) {
  $scope.name = 'Hello World!';
  $scope.testModel = {name: "test"};
  //console.log('This will show log even if debugging is disable');
  $log.debug('TEST Log');
});

Here is Fiddle

Hopefully this will help you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!