Angular 2+ one-time binding

前端 未结 6 1913
故里飘歌
故里飘歌 2020-12-09 14:21

In angular 1 we could do one time binding in this way: {{ ::myFunction() }}.

In angular 2 this is throwing:

EXCEPTION: Template parse er         


        
6条回答
  •  伪装坚强ぢ
    2020-12-09 15:26

    ChangeDetectionStrategy.CheckOnce is the solution for this problem.

    This has been updated to OnPush see also comment in code:

    export declare enum ChangeDetectionStrategy {
        /**
         * `OnPush` means that the change detector's mode will be set to `CheckOnce` during hydration.
         */
        OnPush = 0,
        /**
         * `Default` means that the change detector's mode will be set to `CheckAlways` during hydration.
         */
        Default = 1,
    }
    

提交回复
热议问题