1

Having a problem not being able to show a number like this 40.70, It's showing as 40.7

I tried adding {{number:2}} to different places but just can't get it to work. Any help is greatly appreciated.

this is my current html code:

<td style="width: 10px;">
                        <div class="currency-input">
                            <span class="currency-symbol">$</span>
                            <input type="number" step="0.01" min="0.00" class="currency" ng-model="item.UnitPrice" ng-change="updateQuoteTotals(); formatDecimals(this)" class="form-control text-center input-sm" style="width: 90px; border: 1px solid #CCCCCC; height: 25px;" readonly>z
                        </div>
                    </td>

I know I have to add {{number:2}} somewhere in there just don't know where.

3
  • did you tried to do it in your controller ? Commented Nov 17, 2014 at 14:08
  • Sam offers the correct answer, more information on the currency filter can be found at docs.angularjs.org/api/ng/filter/currency#!. Commented Nov 17, 2014 at 14:35
  • Here is a plnkr I created to try to replicate your problem. plnkr.co/edit/CIVuYr?p=info Commented Nov 17, 2014 at 15:18

2 Answers 2

1

Try like this it should vork

<input type="text" ng-model="val | number:2">
Sign up to request clarification or add additional context in comments.

Comments

1

I think what you want is {{40.70 | currency}}

1 Comment

<input type="number" step="0.01" min="0.00" class="currency" ng-model="item.UnitPrice" ng-change="updateQuoteTotals(); formatDecimals(this)" class="form-control text-center input-sm" style="width: 90px; border: 1px solid #CCCCCC; height: 25px;" readonly>{{40.70 | currency}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.