简体   繁体   中英

One time binding called infinitely many times. Why?

One time binding does not work in AngularJS. Why?

Here is the piece of code:

<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>

Here is the hideRelations function:

function hideRelations(relations, info) {
    return relations;
};

After running the html I see that the hideRelations is called infinitely many times. Why? What may I be missing here?

The framework re-calculates because the function either returns the value undefined or the calculation is unstable.

From the Docs:

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 ).

For more information, see

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM