Samuel Dauzon
Samuel Dauzon

Reputation: 11324

angular format 2 digits ng-value

I'm a newbie on angularJS.

I want to divide 2 numbers, but I want to round the result with two digits.

I try many things :

<input type="number" ng-model="var3" ng-value="var3 = Math.round((var1/var2)*100)/100" />

<input type="number" ng-model="var3" ng-value="var3 = (var1/var2).toFixed(2)" />

Do you have any ideas ?

JsFiddle

Upvotes: 0

Views: 1441

Answers (1)

Igal S.
Igal S.

Reputation: 14543

Not sure how to do it with ng-model and ng-value but this filter works fine:

<input type="number" value="{{ var3=var1/var2 | number:2 }}" />

Upvotes: 1

Related Questions