I have the following:
<td>{{results | number:2}}</td> => esto sale en la vista 120.00
<td>
<input type="number" ng-model="results" step="any"/>
=> esto sale en la vista 120
<input type="number" ng-model="results | number:2" step="any"/>
=> no sale nada en la vista
</td>
What do I have to do to get 120.00 in the input?
That is, the value with two decimal places.
You can refer to this example that does the same thing:
You can use the following library to get the result you want
angular-input-masks
give
You can't use the number directive the way you want ng-model="results | number:2"
I hope it is useful for you.
Good, I leave you the link of the updated and working example. https://jsfiddle.net/Lsv9f0b0/1832/
I have put them
ng-model="$scope.myDecimal"
and it works correctly.Well, I don't handle angularJS and I hope my answer isn't completely useless, but according to the jsfiddle example, and if you look, the second one
input
is of typetext
and hasdisable=true
, and the second one of yours is of typenumber
. The typetext
of the second input in the example should make it easy for the pipe to reflect the two decimal places.You could try a type
text
on the input and use a regex to validate that field in case the user can/should modify it and not just input numbers, or look for some angular directive that updates thevalue
field property (ang-value
or something like ).<input type=number step="0.01" value="120.00"></input>
Interesting your question, I will be pending if someone manages to solve it. Cheers