防爆pression评估2倍 [英] Expression evaluated 2 times

查看:248
本文介绍了防爆pression评估2倍的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的例子:

的test.html

 <!DOCTYPE HTML>
< HTML NG-NG应用程序控制器=AppController的>
    < HEAD>
        <脚本类型=文/ JavaScript的SRC =angular.js>< / SCRIPT>
        <脚本类型=文/ JavaScript的SRC =script1.js>< / SCRIPT>
    < /头>
    <身体GT;
        < D​​IV NG-包括='test1.html'>< / DIV>
        {{testFn()}}
    < /身体GT;
< / HTML>

test1.html

 < D​​IV> {{testFn()}}< / DIV>

script1.js

 函数的AppController($范围){
    $ scope.testFn =功能(){
        的console.log(TestFn);
        返回测试;
    }
}

发生的FN testFn执行4次。我期望看到控制台仅有2日志。甚至,如果我删除

 < D​​IV NG-包括='test1.html'>< / DIV>

有2个数量级,不只是一个。什么了我错了?

更新:

angular.js

  //添加的console.log原来的code
VAR ngBindDirective = ngDirective(功能(范围,元素,属性){
  的console.log(ngDirective,attr.ngBind);
  element.addClass('NG结合)的数据('$结合,attr.ngBind)。
  范围。$腕表(attr.ngBind,功能ngBindWatchAction(值){
    的console.log(ngDirective - 范围$腕表。,值);
    element.text(价值==未定义:价值?);
  });
});

的test.html

 <!DOCTYPE HTML>
< HTML NG-NG应用程序控制器=AppController的>
    < HEAD>
        <脚本类型=文/ JavaScript的SRC =angular.js>< / SCRIPT>
        <脚本类型=文/ JavaScript的SRC =script1.js>< / SCRIPT>
    < /头>
    <身体GT;
        < D​​IV NG绑定=testFn()>< / SPAN>    < /身体GT;
< / HTML>

控制台

  createInjector  -  modulesToLoad未定义angular.js:2666
loadModules未定义angular.js:2756
createInjector - modulesToLoad
[NG,数组[2]
 angular.js:2666
loadModules
[NG,数组[2]
 angular.js:2756
loadModules [ngLocale] angular.js:2756
loadModules [] angular.js:2756
supportObject - 键$区域angular.js:2702
供应商 - 名$区域angular.js:2712
supportObject - 键$编译angular.js:2702
供应商 - 名$编译angular.js:2712
supportObject - 关键aDirective angular.js:2702
工厂 - 名aDirective angular.js:2723
供应商 - 名aDirective angular.js:2712
supportObject - 关键inputDirective angular.js:2702
工厂 - 名inputDirective angular.js:2723
供应商 - 名inputDirective angular.js:2712
supportObject - 关键textareaDirective angular.js:2702
工厂 - 名textareaDirective angular.js:2723
供应商 - 名textareaDirective angular.js:2712
supportObject - 关键formDirective angular.js:2702
工厂 - 名formDirective angular.js:2723
供应商 - 名formDirective angular.js:2712
supportObject - 关键scriptDirective angular.js:2702
工厂 - 名scriptDirective angular.js:2723
供应商 - 名scriptDirective angular.js:2712
supportObject - 关键selectDirective angular.js:2702
工厂 - 名selectDirective angular.js:2723
供应商 - 名selectDirective angular.js:2712
supportObject - 关键styleDirective angular.js:2702
工厂 - 名styleDirective angular.js:2723
供应商 - 名styleDirective angular.js:2712
supportObject - 关键optionDirective angular.js:2702
工厂 - 名optionDirective angular.js:2723
供应商 - 名optionDirective angular.js:2712
supportObject - 关键ngBindDirective angular.js:2702
工厂 - 名ngBindDirective angular.js:2723
供应商 - 名ngBindDirective angular.js:2712
supportObject - 关键ngBindHtmlUnsafeDirective angular.js:2702
工厂 - 名ngBindHtmlUnsafeDirective angular.js:2723
供应商 - 名ngBindHtmlUnsafeDirective angular.js:2712
supportObject - 关键ngBindTemplateDirective angular.js:2702
工厂 - 名ngBindTemplateDirective angular.js:2723
供应商 - 名ngBindTemplateDirective angular.js:2712
supportObject - 关键ngClassDirective angular.js:2702
工厂 - 名ngClassDirective angular.js:2723
供应商 - 名ngClassDirective angular.js:2712
supportObject - 关键ngClassEvenDirective angular.js:2702
工厂 - 名ngClassEvenDirective angular.js:2723
供应商 - 名ngClassEvenDirective angular.js:2712
supportObject - 关键ngClassOddDirective angular.js:2702
工厂 - 名ngClassOddDirective angular.js:2723
供应商 - 名ngClassOddDirective angular.js:2712
supportObject - 关键ngCspDirective angular.js:2702
工厂 - 名ngCspDirective angular.js:2723
供应商 - 名ngCspDirective angular.js:2712
supportObject - 关键ngCloakDirective angular.js:2702
工厂 - 名ngCloakDirective angular.js:2723
供应商 - 名ngCloakDirective angular.js:2712
supportObject - 关键ngControllerDirective angular.js:2702
工厂 - 名ngControllerDirective angular.js:2723
供应商 - 名ngControllerDirective angular.js:2712
supportObject - 关键ngFormDirective angular.js:2702
工厂 - 名ngFormDirective angular.js:2723
供应商 - 名ngFormDirective angular.js:2712
supportObject - 关键ngHideDirective angular.js:2702
工厂 - 名ngHideDirective angular.js:2723
供应商 - 名ngHideDirective angular.js:2712
supportObject - 关键ngIncludeDirective angular.js:2702
工厂 - 名ngIncludeDirective angular.js:2723
供应商 - 名ngIncludeDirective angular.js 2712
supportObject - 关键ngInitDirective angular.js:2702
工厂 - 名ngInitDirective angular.js:2723
供应商 - 名ngInitDirective angular.js:2712
supportObject - 关键ngNonBindableDirective angular.js:2702
工厂 - 名ngNonBindableDirective angular.js:2723
供应商 - 名ngNonBindableDirective angular.js:2712
supportObject - 关键ngPluralizeDirective angular.js:2702
工厂 - 名ngPluralizeDirective angular.js:2723
供应商 - 名ngPluralizeDirective angular.js:2712
supportObject - 关键ngRepeatDirective angular.js:2702
工厂 - 名ngRepeatDirective angular.js:2723
供应商 - 名ngRepeatDirective angular.js:2712
supportObject - 关键ngShowDirective angular.js:2702
工厂 - 名ngShowDirective angular.js:2723
供应商 - 名ngShowDirective angular.js:2712
supportObject - 关键ngSubmitDirective angular.js:2702
工厂 - 名ngSubmitDirective angular.js:2723
供应商 - 名ngSubmitDirective angular.js:2712
supportObject - 关键ngStyleDirective angular.js:2702
工厂 - 名ngStyleDirective angular.js:2723
供应商 - 名ngStyleDirective angular.js:2712
supportObject - 关键ngSwitchDirective angular.js:2702
工厂 - 名ngSwitchDirective angular.js:2723
供应商 - 名ngSwitchDirective angular.js:2712
supportObject - 关键ngSwitchWhenDirective angular.js:2702
工厂 - 名ngSwitchWhenDirective angular.js:2723
供应商 - 名ngSwitchWhenDirective angular.js:2712
supportObject - 关键ngSwitchDefaultDirective angular.js:2702
工厂 - 名ngSwitchDefaultDirective angular.js:2723
供应商 - 名ngSwitchDefaultDirective angular.js:2712
supportObject - 关键ngOptionsDirective angular.js:2702
工厂 - 名ngOptionsDirective angular.js:2723
供应商 - 名ngOptionsDirective angular.js:2712
supportObject - 关键ngViewDirective angular.js:2702
工厂 - 名ngViewDirective angular.js:2723
供应商 - 名ngViewDirective angular.js:2712
supportObject - 关键ngTranscludeDirective angular.js:2702
工厂 - 名ngTranscludeDirective angular.js:2723
供应商 - 名ngTranscludeDirective angular.js:2712
supportObject - 关键ngModelDirective angular.js:2702
工厂 - 名ngModelDirective angular.js:2723
供应商 - 名ngModelDirective angular.js:2712
supportObject - 关键ngListDirective angular.js:2702
工厂 - 名ngListDirective angular.js:2723
供应商 - 名ngListDirective angular.js:2712
supportObject - 关键ngChangeDirective angular.js:2702
工厂 - 名ngChangeDirective angular.js:2723
供应商 - 名ngChangeDirective angular.js:2712
supportObject - 关键requiredDirective angular.js:2702
工厂 - 名requiredDirective angular.js:2723
供应商 - 名requiredDirective angular.js:2712
supportObject - 关键ngRequiredDirective angular.js:2702
工厂 - 名ngRequiredDirective angular.js:2723
供应商 - 名ngRequiredDirective angular.js 2712
supportObject - 关键ngValueDirective angular.js:2702
工厂 - 名ngValueDirective angular.js:2723
供应商 - 名ngValueDirective angular.js:2712
supportObject - 关键ngMultipleDirective angular.js:2702
工厂 - 名ngMultipleDirective angular.js:2723
供应商 - 名ngMultipleDirective angular.js:2712
supportObject - 关键ngSelectedDirective angular.js:2702
工厂 - 名ngSelectedDirective angular.js:2723
供应商 - 名ngSelectedDirective angular.js:2712
supportObject - 关键ngCheckedDirective angular.js:2702
工厂 - 名ngCheckedDirective angular.js:2723
供应商 - 名ngCheckedDirective angular.js:2712
supportObject - 关键ngDisabledDirective angular.js:2702
工厂 - 名ngDisabledDirective angular.js:2723
供应商 - 名ngDisabledDirective angular.js:2712
supportObject - 关键ngReadonlyDirective angular.js:2702
工厂 - 名ngReadonlyDirective angular.js:2723
供应商 - 名ngReadonlyDirective angular.js:2712
supportObject - 关键ngSrcDirective angular.js:2702
工厂 - 名ngSrcDirective angular.js:2723
供应商 - 名ngSrcDirective angular.js:2712
supportObject - 关键ngHrefDirective angular.js:2702
工厂 - 名ngHrefDirective angular.js:2723
供应商 - 名ngHrefDirective angular.js:2712
supportObject - 关键ngClickDirective angular.js:2702
工厂 - 名ngClickDirective angular.js:2723
供应商 - 名ngClickDirective angular.js:2712
supportObject - 关键ngDblclickDirective angular.js:2702
工厂 - 名ngDblclickDirective angular.js:2723
供应商 - 名ngDblclickDirective angular.js:2712
supportObject - 关键ngMousedownDirective angular.js:2702
工厂 - 名ngMousedownDirective angular.js:2723
供应商 - 名ngMousedownDirective angular.js:2712
supportObject - 关键ngMouseupDirective angular.js:2702
工厂 - 名ngMouseupDirective angular.js:2723
供应商 - 名ngMouseupDirective angular.js:2712
supportObject - 关键ngMouseoverDirective angular.js:2702
工厂 - 名ngMouseoverDirective angular.js:2723
供应商 - 名ngMouseoverDirective angular.js 2712
supportObject - 关键ngMouseoutDirective angular.js:2702
工厂 - 名ngMouseoutDirective angular.js:2723
供应商 - 名ngMouseoutDirective angular.js:2712
supportObject - 关键ngMousemoveDirective angular.js:2702
工厂 - 名ngMousemoveDirective angular.js:2723
供应商 - 名ngMousemoveDirective angular.js:2712
supportObject - 关键ngMouseenterDirective angular.js:2702
工厂 - 名ngMouseenterDirective angular.js:2723
供应商 - 名ngMouseenterDirective angular.js:2712
supportObject - 关键ngMouseleaveDirective angular.js:2702
工厂 - 名ngMouseleaveDirective angular.js:2723
供应商 - 名ngMouseleaveDirective angular.js:2712
supportObject - 关键
对象{$ anchorScroll:函数,$浏览器:函数,$ cacheFactory:函数,$控制器:函数,$文件:函数...}
 angular.js:2702
供应商 - 名$ anchorScroll angular.js:2712
供应商 - 名$浏览器angular.js:2712
供应商 - 名$ cacheFactory angular.js:2712
供应商 - 名$控制器angular.js:2712
供应商 - 名称$文件angular.js:2712
供应商 - 名$ exceptionHandler的angular.js:2712
供应商 - 名$过滤angular.js 2712
supportObject - 关键currencyFilter angular.js:2702
工厂 - 名currencyFilter angular.js:2723
供应商 - 名currencyFilter angular.js:2712
supportObject - 关键dateFilter angular.js:2702
工厂 - 名dateFilter angular.js:2723
供应商 - 名dateFilter angular.js:2712
supportObject - 关键filterFilter angular.js:2702
工厂 - 名filterFilter angular.js:2723
供应商 - 名filterFilter angular.js:2712
supportObject - 关键jsonFilter angular.js:2702
工厂 - 名jsonFilter angular.js:2723
供应商 - 名jsonFilter angular.js:2712
supportObject - 关键limitToFilter angular.js:2702
工厂 - 名limitToFilter angular.js:2723
供应商 - 名limitToFilter angular.js:2712
supportObject - 关键lowercaseFilter angular.js:2702
工厂 - 名lowercaseFilter angular.js:2723
供应商 - 名lowercaseFilter angular.js:2712
supportObject - 关键numberFilter angular.js:2702
工厂 - 名numberFilter angular.js:2723
供应商 - 名numberFilter angular.js:2712
supportObject - 关键orderByFilter angular.js:2702
工厂 - 名orderByFilter angular.js:2723
供应商 - 名orderByFilter angular.js:2712
supportObject - 关键uppercaseFilter angular.js:2702
工厂 - 名uppercaseFilter angular.js:2723
供应商 - 名uppercaseFilter angular.js:2712
供应商 - 名$插值angular.js:2712
供应商 - 名$ HTTP angular.js:2712
供应商 - 名$ httpBackend angular.js:2712
供应商 - 名称$位置angular.js:2712
供应商 - 名$日志angular.js:2712
供应商 - 名称解析$ angular.js:2712
供应商 - 名$航线angular.js:2712
供应商 - 名$ routeParams angular.js:2712
供应商 - 名$ rootScope angular.js:2712
供应商 - 名$ Q angular.js:2712
供应商 - 名$嗅探angular.js:2712
供应商 - 名$ templateCache angular.js:2712
供应商 - 名$超时angular.js:2712
供应商 - 名$窗口angular.js:2712
装饰 - SERVICENAME $ rootScope angular.js:2742
supportObject - 键$ rootElement的angular.js:2702
工厂 - 名$ rootElement的angular.js:2723
供应商 - 名$ rootElement的angular.js:2712
---------------------------------------------
ngDirective testFn()angular.js:12363
TestFn script1.js:3
。ngDirective - 范围$手表测试angular.js:12366
TestFn script1.js:3


解决方案

更​​新:

当插入该视图前pressions和运行摘要周期角度将重新运行/插值每个EX pression至少两次,以'正常化它渲染(见本的 GitHub上的问题这的 SO帖子)。

因此​​,这是正常现象。

对于这个问题,如果你使用鉴于前pressions范围的方法,这些方法应幂等(它们应该提供相同的输出给定相同的输入)。

In following example:

test.html

<!DOCTYPE html>
<html ng-app ng-controller="AppController">
    <head>
        <script type="text/javascript"  src="angular.js"></script>
        <script type="text/javascript"  src="script1.js"></script>
    </head>
    <body>
        <div ng-include="'test1.html'"></div>
        {{testFn()}}
    </body>
</html>

test1.html

<div>{{testFn()}}</div>

script1.js

function AppController($scope) {
    $scope.testFn = function() {
        console.log("TestFn");
        return "test";
    }
}

happen that fn testFn executes 4 times. I expected to see just 2 logs in console. Even, if I remove

<div ng-include="'test1.html'"></div>

there are 2 logs, not just one. What did I wrong?

UPDATED:

angular.js

// added console.log to original code
var ngBindDirective = ngDirective(function(scope, element, attr) {
  console.log("ngDirective", attr.ngBind);
  element.addClass('ng-binding').data('$binding', attr.ngBind);
  scope.$watch(attr.ngBind, function ngBindWatchAction(value) {
    console.log("ngDirective - scope.$watch", value);
    element.text(value == undefined ? '' : value);
  });
});

test.html

<!DOCTYPE html>
<html ng-app ng-controller="AppController">
    <head>
        <script type="text/javascript"  src="angular.js"></script>
        <script type="text/javascript"  src="script1.js"></script>
    </head>
    <body>
        <div ng-bind="testFn()"></span>

    </body>
</html>

console

createInjector - modulesToLoad undefined angular.js:2666
loadModules undefined angular.js:2756
createInjector - modulesToLoad 
["ng", Array[2]]
 angular.js:2666
loadModules 
["ng", Array[2]]
 angular.js:2756
loadModules ["ngLocale"] angular.js:2756
loadModules [] angular.js:2756
supportObject - key $locale angular.js:2702
provider - name $locale angular.js:2712
supportObject - key $compile angular.js:2702
provider - name $compile angular.js:2712
supportObject - key aDirective angular.js:2702
factory - name aDirective angular.js:2723
provider - name aDirective angular.js:2712
supportObject - key inputDirective angular.js:2702
factory - name inputDirective angular.js:2723
provider - name inputDirective angular.js:2712
supportObject - key textareaDirective angular.js:2702
factory - name textareaDirective angular.js:2723
provider - name textareaDirective angular.js:2712
supportObject - key formDirective angular.js:2702
factory - name formDirective angular.js:2723
provider - name formDirective angular.js:2712
supportObject - key scriptDirective angular.js:2702
factory - name scriptDirective angular.js:2723
provider - name scriptDirective angular.js:2712
supportObject - key selectDirective angular.js:2702
factory - name selectDirective angular.js:2723
provider - name selectDirective angular.js:2712
supportObject - key styleDirective angular.js:2702
factory - name styleDirective angular.js:2723
provider - name styleDirective angular.js:2712
supportObject - key optionDirective angular.js:2702
factory - name optionDirective angular.js:2723
provider - name optionDirective angular.js:2712
supportObject - key ngBindDirective angular.js:2702
factory - name ngBindDirective angular.js:2723
provider - name ngBindDirective angular.js:2712
supportObject - key ngBindHtmlUnsafeDirective angular.js:2702
factory - name ngBindHtmlUnsafeDirective angular.js:2723
provider - name ngBindHtmlUnsafeDirective angular.js:2712
supportObject - key ngBindTemplateDirective angular.js:2702
factory - name ngBindTemplateDirective angular.js:2723
provider - name ngBindTemplateDirective angular.js:2712
supportObject - key ngClassDirective angular.js:2702
factory - name ngClassDirective angular.js:2723
provider - name ngClassDirective angular.js:2712
supportObject - key ngClassEvenDirective angular.js:2702
factory - name ngClassEvenDirective angular.js:2723
provider - name ngClassEvenDirective angular.js:2712
supportObject - key ngClassOddDirective angular.js:2702
factory - name ngClassOddDirective angular.js:2723
provider - name ngClassOddDirective angular.js:2712
supportObject - key ngCspDirective angular.js:2702
factory - name ngCspDirective angular.js:2723
provider - name ngCspDirective angular.js:2712
supportObject - key ngCloakDirective angular.js:2702
factory - name ngCloakDirective angular.js:2723
provider - name ngCloakDirective angular.js:2712
supportObject - key ngControllerDirective angular.js:2702
factory - name ngControllerDirective angular.js:2723
provider - name ngControllerDirective angular.js:2712
supportObject - key ngFormDirective angular.js:2702
factory - name ngFormDirective angular.js:2723
provider - name ngFormDirective angular.js:2712
supportObject - key ngHideDirective angular.js:2702
factory - name ngHideDirective angular.js:2723
provider - name ngHideDirective angular.js:2712
supportObject - key ngIncludeDirective angular.js:2702
factory - name ngIncludeDirective angular.js:2723
provider - name ngIncludeDirective angular.js:2712
supportObject - key ngInitDirective angular.js:2702
factory - name ngInitDirective angular.js:2723
provider - name ngInitDirective angular.js:2712
supportObject - key ngNonBindableDirective angular.js:2702
factory - name ngNonBindableDirective angular.js:2723
provider - name ngNonBindableDirective angular.js:2712
supportObject - key ngPluralizeDirective angular.js:2702
factory - name ngPluralizeDirective angular.js:2723
provider - name ngPluralizeDirective angular.js:2712
supportObject - key ngRepeatDirective angular.js:2702
factory - name ngRepeatDirective angular.js:2723
provider - name ngRepeatDirective angular.js:2712
supportObject - key ngShowDirective angular.js:2702
factory - name ngShowDirective angular.js:2723
provider - name ngShowDirective angular.js:2712
supportObject - key ngSubmitDirective angular.js:2702
factory - name ngSubmitDirective angular.js:2723
provider - name ngSubmitDirective angular.js:2712
supportObject - key ngStyleDirective angular.js:2702
factory - name ngStyleDirective angular.js:2723
provider - name ngStyleDirective angular.js:2712
supportObject - key ngSwitchDirective angular.js:2702
factory - name ngSwitchDirective angular.js:2723
provider - name ngSwitchDirective angular.js:2712
supportObject - key ngSwitchWhenDirective angular.js:2702
factory - name ngSwitchWhenDirective angular.js:2723
provider - name ngSwitchWhenDirective angular.js:2712
supportObject - key ngSwitchDefaultDirective angular.js:2702
factory - name ngSwitchDefaultDirective angular.js:2723
provider - name ngSwitchDefaultDirective angular.js:2712
supportObject - key ngOptionsDirective angular.js:2702
factory - name ngOptionsDirective angular.js:2723
provider - name ngOptionsDirective angular.js:2712
supportObject - key ngViewDirective angular.js:2702
factory - name ngViewDirective angular.js:2723
provider - name ngViewDirective angular.js:2712
supportObject - key ngTranscludeDirective angular.js:2702
factory - name ngTranscludeDirective angular.js:2723
provider - name ngTranscludeDirective angular.js:2712
supportObject - key ngModelDirective angular.js:2702
factory - name ngModelDirective angular.js:2723
provider - name ngModelDirective angular.js:2712
supportObject - key ngListDirective angular.js:2702
factory - name ngListDirective angular.js:2723
provider - name ngListDirective angular.js:2712
supportObject - key ngChangeDirective angular.js:2702
factory - name ngChangeDirective angular.js:2723
provider - name ngChangeDirective angular.js:2712
supportObject - key requiredDirective angular.js:2702
factory - name requiredDirective angular.js:2723
provider - name requiredDirective angular.js:2712
supportObject - key ngRequiredDirective angular.js:2702
factory - name ngRequiredDirective angular.js:2723
provider - name ngRequiredDirective angular.js:2712
supportObject - key ngValueDirective angular.js:2702
factory - name ngValueDirective angular.js:2723
provider - name ngValueDirective angular.js:2712
supportObject - key ngMultipleDirective angular.js:2702
factory - name ngMultipleDirective angular.js:2723
provider - name ngMultipleDirective angular.js:2712
supportObject - key ngSelectedDirective angular.js:2702
factory - name ngSelectedDirective angular.js:2723
provider - name ngSelectedDirective angular.js:2712
supportObject - key ngCheckedDirective angular.js:2702
factory - name ngCheckedDirective angular.js:2723
provider - name ngCheckedDirective angular.js:2712
supportObject - key ngDisabledDirective angular.js:2702
factory - name ngDisabledDirective angular.js:2723
provider - name ngDisabledDirective angular.js:2712
supportObject - key ngReadonlyDirective angular.js:2702
factory - name ngReadonlyDirective angular.js:2723
provider - name ngReadonlyDirective angular.js:2712
supportObject - key ngSrcDirective angular.js:2702
factory - name ngSrcDirective angular.js:2723
provider - name ngSrcDirective angular.js:2712
supportObject - key ngHrefDirective angular.js:2702
factory - name ngHrefDirective angular.js:2723
provider - name ngHrefDirective angular.js:2712
supportObject - key ngClickDirective angular.js:2702
factory - name ngClickDirective angular.js:2723
provider - name ngClickDirective angular.js:2712
supportObject - key ngDblclickDirective angular.js:2702
factory - name ngDblclickDirective angular.js:2723
provider - name ngDblclickDirective angular.js:2712
supportObject - key ngMousedownDirective angular.js:2702
factory - name ngMousedownDirective angular.js:2723
provider - name ngMousedownDirective angular.js:2712
supportObject - key ngMouseupDirective angular.js:2702
factory - name ngMouseupDirective angular.js:2723
provider - name ngMouseupDirective angular.js:2712
supportObject - key ngMouseoverDirective angular.js:2702
factory - name ngMouseoverDirective angular.js:2723
provider - name ngMouseoverDirective angular.js:2712
supportObject - key ngMouseoutDirective angular.js:2702
factory - name ngMouseoutDirective angular.js:2723
provider - name ngMouseoutDirective angular.js:2712
supportObject - key ngMousemoveDirective angular.js:2702
factory - name ngMousemoveDirective angular.js:2723
provider - name ngMousemoveDirective angular.js:2712
supportObject - key ngMouseenterDirective angular.js:2702
factory - name ngMouseenterDirective angular.js:2723
provider - name ngMouseenterDirective angular.js:2712
supportObject - key ngMouseleaveDirective angular.js:2702
factory - name ngMouseleaveDirective angular.js:2723
provider - name ngMouseleaveDirective angular.js:2712
supportObject - key 
Object {$anchorScroll: function, $browser: function, $cacheFactory: function, $controller: function, $document: function…}
 angular.js:2702
provider - name $anchorScroll angular.js:2712
provider - name $browser angular.js:2712
provider - name $cacheFactory angular.js:2712
provider - name $controller angular.js:2712
provider - name $document angular.js:2712
provider - name $exceptionHandler angular.js:2712
provider - name $filter angular.js:2712
supportObject - key currencyFilter angular.js:2702
factory - name currencyFilter angular.js:2723
provider - name currencyFilter angular.js:2712
supportObject - key dateFilter angular.js:2702
factory - name dateFilter angular.js:2723
provider - name dateFilter angular.js:2712
supportObject - key filterFilter angular.js:2702
factory - name filterFilter angular.js:2723
provider - name filterFilter angular.js:2712
supportObject - key jsonFilter angular.js:2702
factory - name jsonFilter angular.js:2723
provider - name jsonFilter angular.js:2712
supportObject - key limitToFilter angular.js:2702
factory - name limitToFilter angular.js:2723
provider - name limitToFilter angular.js:2712
supportObject - key lowercaseFilter angular.js:2702
factory - name lowercaseFilter angular.js:2723
provider - name lowercaseFilter angular.js:2712
supportObject - key numberFilter angular.js:2702
factory - name numberFilter angular.js:2723
provider - name numberFilter angular.js:2712
supportObject - key orderByFilter angular.js:2702
factory - name orderByFilter angular.js:2723
provider - name orderByFilter angular.js:2712
supportObject - key uppercaseFilter angular.js:2702
factory - name uppercaseFilter angular.js:2723
provider - name uppercaseFilter angular.js:2712
provider - name $interpolate angular.js:2712
provider - name $http angular.js:2712
provider - name $httpBackend angular.js:2712
provider - name $location angular.js:2712
provider - name $log angular.js:2712
provider - name $parse angular.js:2712
provider - name $route angular.js:2712
provider - name $routeParams angular.js:2712
provider - name $rootScope angular.js:2712
provider - name $q angular.js:2712
provider - name $sniffer angular.js:2712
provider - name $templateCache angular.js:2712
provider - name $timeout angular.js:2712
provider - name $window angular.js:2712
decorator - serviceName $rootScope angular.js:2742
supportObject - key $rootElement angular.js:2702
factory - name $rootElement angular.js:2723
provider - name $rootElement angular.js:2712
---------------------------------------------
ngDirective testFn() angular.js:12363
TestFn script1.js:3
ngDirective - scope.$watch test angular.js:12366
TestFn script1.js:3

解决方案

UPDATE:

When interpolating the view expressions and running the digest cycle Angular will re-run/interpolate each expression at least twice, in order to 'normalize it' before rendering (See this github issue and this SO post).

Thus, this is expected behavior.

For that matter, if you're using scope methods in view expressions, these methods should be idempotent (they should provide the same output given the same input).

这篇关于防爆pression评估2倍的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆