动作表达式中不能包含管道? [英] Cannot have a pipe in an action expression ?
本文介绍了动作表达式中不能包含管道?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在html模板中使用了以下语句:
I'm using this statement in my html template:
[(ngModel)]="tempProduct.unitprice | number : '1.2-2'"
但是当我运行它时,我在控制台中得到了这个错误:
But when i run it im getting this error in console:
动作表达式中不能包含管道...
Cannot have a pipe in an action expression...
我需要使用此号码管道,但要使用[(ngModel)]
,否则我将无法获取数据.任何建议,我该如何解决?我尝试了[ngModel]
,但是当我这样做时却没有获取数据,因此它在html模板中为空.
I need to use this number pipe but with [(ngModel)]
or i will not get data. Any suggestion how can i fix this?? I tried with [ngModel]
but when i do that i dont get data, its empty in html template.
推荐答案
这可能适合您:
[ngModel]="tempProduct.unitprice | number : '1.2-2'" (ngModelChange)="tempProduct.unitprice = $event"
通过这种方式,双向"绑定分为属性绑定和事件绑定,这使得表达式更加复杂.
This way "two-way"-binding is split in property-binding and event binding which allows more complex expressions.
这篇关于动作表达式中不能包含管道?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文