Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Currency pipe with a 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 have to pass the currency from the model variable, this is what i am doing,

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

and in template,

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

it gives me a template parse error. what is the issue.

like image 847
Sajeetharan Avatar asked Feb 17 '17 07:02

Sajeetharan


1 Answers

Don't nest {{}}

   <div class="price">{{123 | currConvert | currency:selectedCurrency:true:'3.2-2'}}</div>
like image 75
Günter Zöchbauer Avatar answered Sep 19 '22 19:09

Günter Zöchbauer