Reputation: 4665
I have found an example which limits a number to 2 decimal places AND turns the figure into a currency amount- eg £2.55.
{{ number | currency : 'GBP' : true : '1.2-2'}}
Is there a simple pipe which does the same without applying a currency?
Upvotes: 158
Views: 285849
Reputation: 312
It's Works
.ts -> pi = 3.1415
.html -> {{ pi | number : '1.0-2' }}
Ouput -> 3.14
https://stackblitz.com/edit/angular-e8g2pt?file=src/app/app.component.html
this works for me!!! thanks!!
Upvotes: 16
Reputation: 5264
Simple solution
{{ orderTotal | number : '1.2-2'}}
//output like this
// public orderTotal = 220.45892221
// {{ orderTotal | number : '1.2-2'}}
// final Output
// 220.45
Upvotes: 7
Reputation: 906
Well now will be different after angular 5:
{{ number | currency :'GBP':'symbol':'1.2-2' }}
Upvotes: 10