Reputation: 45
I am facing issues with angular pipe. I am building an application using reactive forms that perform calculation and display cost. When it is calculated for first time then it displays currency pipe but when i again calculate it and if the result cost comes same then currency pipe is not displayed instead it shows only number.It works fine if the cost changes everytime.
<input type="text" [value]="AccountingForm.get('Cost').value |currency:'USD'"
formControlName="Cost" class="form-control">
For example when i calculate , it shows $100.00 and when i again calculate it and cost remain same then it shows 100 without currency pipe.
in calculate method i am setting like this
this.AccountingForm.controls['Cost'].setValue(value);
Upvotes: 1
Views: 1769
Reputation: 72
Instead of using pipe, try to implement the same thing in your ts file
Upvotes: 0
Reputation: 10979
Make your pipe impure to resolve it. Include pure false in your pipe decorator.
@Pipe({
name: 'flyingHeroesImpure',
pure: false
})
Upvotes: 3