NewBee
NewBee

Reputation: 41

2 Decimal Places in a <span> element in Angular

In my angular app, I have a span element where I need to display some values from service response.

Currently it is showing like

> value = 20.00000000000

whereas I want to display in the following manner

> value = 20.00

The problem is I have to display the value in a <span> element. I want to achieve it without using regex.

Any help would be appreciated.

Upvotes: 0

Views: 824

Answers (1)

npinti
npinti

Reputation: 52195

Since you are using angular, you can do something like so: <span>{{value | number:2}}</span>. This should render your value parameter to 2 decimal places.

Upvotes: 1

Related Questions