Angular 2+ 一次性绑定 [英] Angular 2+ one-time binding

查看:31
本文介绍了Angular 2+ 一次性绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 angular 1 中,我们可以通过这种方式进行一次绑定:{{ ::myFunction() }}.

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

在 angular 2 中这是抛出:

In angular 2 this is throwing:

EXCEPTION: Template parse errors:
Parser Error: Unexpected token : at column 2 in [{{ ::consent(false, undefined, box) }}] in CookieConsent@5:29 ("ull-right" href="" (click)="consent(true, $event, box)">De acuerdo</a>
        <span class="hidden">[ERROR ->]{{ ::consent(false, undefined, box) }}</span>

如何在 angular2 中一次性绑定?

How can we do one time binding in angular2?

推荐答案

ChangeDetectionStrategy.CheckOnce 是这个问题的解决方案.

ChangeDetectionStrategy.CheckOnce is the solution for this problem.

这里有一些信息:

https://angular.io/docs/ts/latest/api/core/index/ChangeDetectionStrategy-enum.html

这篇关于Angular 2+ 一次性绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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