Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 已为Angular 1.2启用调试信息_Javascript_Angularjs_Debugging_Internet Explorer 8_Backport - Fatal编程技术网

Javascript 已为Angular 1.2启用调试信息

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

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、ngBindHtml或{…}插值的元素
作为一种可能的选择,我可以分叉angularjs存储库,并将该特性向后移植到1.2。然后,使用fork从上游维护更新


如果有任何提示,我们将不胜感激。

您可以尝试通过提及
$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');
});
这里是


希望这将对您有所帮助。

使用底层DOM
setAttribute
方法来防止默认行为。我在另一个答案中编辑了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);
}