Sufail Kalathil
Sufail Kalathil

Reputation: 647

Angular Default Currency Pipe not working along with amount

I have a problem with the already built in CurrencyPipe from Angular. I have tried with following

<div class="row">
  <div class="col-7"><p>Delivery fee </p></div>
  <div class="col-5 text-right">
    <p>{{cartService.getItems().length > 0 ? 10 : 0 | currency:'INR':'symbol-narrow'}} </p>
  </div>
</div>

It display only the value not displaying currency along with the amount.

Output:

10

Expected output

₹10

I am also using angular pipe for displaying another amount. which is working perfectly along with amount.

<div class="row pad-top20">
  <div class="col-7"><p><strong>Total</strong></p></div>
  <div class="col-5 text-right">
    <p><strong>{{calculateGrandTotal() | currency:'INR':'symbol-narrow'}}</strong></p>
  </div>
</div>

Output :

₹22,180.00

What is the difference between these two angular currency pipes ? Thanks!!

Upvotes: 1

Views: 2579

Answers (2)

Sufail Kalathil
Sufail Kalathil

Reputation: 647

I have added currency pipe for both condition.

<div class="row">
      <div class="col-7"><p>Delivery fee </p></div>
      <div class="col-5 text-right">
        <p>{{cartService.getItems().length > 0 ? (10| currency:'INR':'symbol-narrow') : (0 | currency:'INR':'symbol-narrow')}} </p></div>
</div>

Upvotes: 0

pynode
pynode

Reputation: 434

You will need to add ( and ) before currency pipe in code. Like this.

<div class="row">
  <div class="col-7"><p>Delivery fee </p></div>
  <div class="col-5 text-right">
    <p>{{(cartService.getItems().length > 0 ? 10 : 0) | currency:'INR':'symbol-narrow'}} </p>
  </div>
</div>

Upvotes: 3

Related Questions