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

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

问题描述

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

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

在角度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天全站免登陆