Currency pipe with dynamic currency variable in angular2

I am using CurrencyPipe with my application,

The following works,

 <div class="price">{{123 | currConvert | currency:'USD':true:'3.2-2'}}</div>

Now I need to transfer the currency from the model variable, this is what I do,

  ngOnInit() {
         this.selectedCurrency = 'USD';
     }

and in the template

   <div class="price">{{123 | currConvert | currency:{{selectedCurrency}}:true:'3.2-2'}}</div>

it gives me the parsing error of the template. what is the problem.

+4
source share
1 answer

Not a nest {{}}

   <div class="price">{{123 | currConvert | currency:selectedCurrency:true:'3.2-2'}}</div>
+7
source

Source: https://habr.com/ru/post/1670023/


All Articles