Javascript 已为Angular 1.2启用调试信息
Angular 1.3引入了一种新方法,如果在以下位置使用Javascript 已为Angular 1.2启用调试信息,javascript,angularjs,debugging,internet-explorer-8,backport,Javascript,Angularjs,Debugging,Internet Explorer 8,Backport,Angular 1.3引入了一种新方法,如果在以下位置使用false调用,可以提高性能: 此外,Angular 1.3放弃了IE8支持。这对我来说是个问题,我的应用程序必须在IE8上运行。因此,我无法升级到angular 1.3,只能使用angular 1.2 有没有办法实现angular 1.2的相同功能 特别是,debugInfoEnabled()至少有一部分功能: 在创建新范围时,防止创建ng范围/ng隔离范围CSS类 不要将绑定数据和ng类CSS类附加到带有ngBind、ngBindH
false
调用,可以提高性能:
此外,Angular 1.3放弃了IE8支持。这对我来说是个问题,我的应用程序必须在IE8上运行。因此,我无法升级到angular 1.3,只能使用angular 1.2
有没有办法实现angular 1.2的相同功能
特别是,debugInfoEnabled()
至少有一部分功能:
- 在创建新范围时,防止创建
/ng范围
CSS类ng隔离范围
- 不要将绑定数据和ng类CSS类附加到带有ngBind、ngBindHtml或{…}插值的元素
如果有任何提示,我们将不胜感激。您可以尝试通过提及
$logProvider.debugEnabled(true)来禁用它代码>在角度配置内。
为了使debugEnabled
设置生效,您需要确保在执行日志时使用$log
提供程序
示例代码
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');
});
这里是
希望这将对您有所帮助。使用底层DOMsetAttribute
方法来防止默认行为。我在另一个答案中编辑了plunker:
要执行以下操作:
- 克隆DOM
setAttribute
prototype方法
- 通过检查
ng
debug属性覆盖它
- 对于
ng
debug属性返回false
- 正常返回,否则返回
按如下方式使用:
/* 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);
}
将IE8的HTMLElement
替换为元素
参考资料
您使用的angular的确切版本是什么?它是1.2.7还是小于1.2.7it@pankajparkar试图坚持使用最新的1.2.*
。当前1.2.28
。Thank.try app.config(函数($logProvider){$logProvider.debugEnabled(true);});在你的应用程序里面有一个Angular 1.3的构建,它将与IE8@Fergal一起工作,非常感谢。非常感谢。谢谢,但我想会的。。
/* 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);
}