inpu控件接受pipe的处理结果

input控件绑定的变量,要接受用户的输入值,一般只要使用   [(ngModel)]  就可以。

但是,pipe处理结果如何反映到变量里去呢?不知道吧?嘿嘿

这样就可以了 :  <input type="text" [ngModel]="testText | test-pipe" (ngModelChange)="testText=$event" />

就是用ngModelChange事件监听变化(监听谁的变化?pipe?input?不知道),把变化反映给input控件绑定的变量。

猜你喜欢

转载自www.cnblogs.com/nliao/p/10198731.html