Cannot have a pipe in an action expression ?

后端 未结 2 538
清歌不尽
清歌不尽 2020-12-31 01:22

I\'m using this statement in my html template:

[(ngModel)]=\"tempProduct.unitprice | number : \'1.2-2\'\"

But when i run it im getting this

相关标签:
2条回答
  • 2020-12-31 02:08

    Perhaps this should work for you:

    [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.

    0 讨论(0)
  • 2020-12-31 02:11

    Thanks! Fun fact: this works with ng2-dragula too!

    <div [dragula]="'COPYABLE'" [dragulaModel]="service.model.players | PlayerFilterPipe: queryString" (ngModelChange)="service.model.players = $event">
        <div *ngFor="let player of service.model.players | PlayerFilterPipe: queryString">{{player.name}}</div>
    
    0 讨论(0)
提交回复
热议问题