一次绑定调用无限次。为什么?
One time binding called infinitely many times. Why?
一次性绑定在 AngularJS 中不起作用。为什么?
这是一段代码:
<div ng-repeat="c in ::relatedCasesInfo.hideRelations(type.cases, info)
| limitTo:relatedCasesInfo.initialRelationsAmount track by c.idFromFirst"
class="initial-case-container">
<ng-include ng-repeat="name in [c.name + (type.otherCasesArePresent || !$last || type.cases.length > relatedCasesInfo.initialRelationsAmount ? ', ' : '' )]"
src="'dist/directiveTemplates/card/controls/relatedCases/casesContextMenu.html?v=' + $root.appVersion">
</ng-include>
</div>
这里是 hideRelations
函数:
function hideRelations(relations, info) {
return relations;
};
在 运行 之后 html 我看到 hideRelations
被调用了无数次。为什么?我可能在这里遗漏了什么?
框架重新计算,因为函数 returns 值 undefined
或计算不稳定。
来自文档:
One-time binding
An expression that starts with ::
is considered a one-time expression. One-time expressions will stop recalculating once they are stable, which happens after the first digest if the expression result is a non-undefined value (see value stabilization algorithm).
有关详细信息,请参阅
一次性绑定在 AngularJS 中不起作用。为什么?
这是一段代码:
<div ng-repeat="c in ::relatedCasesInfo.hideRelations(type.cases, info)
| limitTo:relatedCasesInfo.initialRelationsAmount track by c.idFromFirst"
class="initial-case-container">
<ng-include ng-repeat="name in [c.name + (type.otherCasesArePresent || !$last || type.cases.length > relatedCasesInfo.initialRelationsAmount ? ', ' : '' )]"
src="'dist/directiveTemplates/card/controls/relatedCases/casesContextMenu.html?v=' + $root.appVersion">
</ng-include>
</div>
这里是 hideRelations
函数:
function hideRelations(relations, info) {
return relations;
};
在 运行 之后 html 我看到 hideRelations
被调用了无数次。为什么?我可能在这里遗漏了什么?
框架重新计算,因为函数 returns 值 undefined
或计算不稳定。
来自文档:
One-time binding
An expression that starts with
::
is considered a one-time expression. One-time expressions will stop recalculating once they are stable, which happens after the first digest if the expression result is a non-undefined value (see value stabilization algorithm).
有关详细信息,请参阅