I am using knockout to populate number values inside a table:
HTML:
<tbody data-bind="foreach: commision">
<tr>
<td>
<span>R </span><span data-bind="text: Amount"></span>
</td>
</tr>...
</tbody>
Knockout.js part pertaining to amount and commision
var vm = {
commision: ko.observable(),
futurecommision: ko.observable(),
commisionpaid: ko.observable(),
totals: ko.observable(),
commisionPaid: ko.observable(ko.utils.unwrapObservable(ko.mapping.fromJS({
Date: null,
Amount: 0
}))),
...
Now how do i show the number being populated in decimal fomat, say .00 ? eg. 10.00
Currently it is only showing the number, eg 10
Have a look at this KO Money Extender:
http://jsfiddle.net/digitalbush/R6MPU/
You could look into writing a custom extender to handle this.
A basic extender is something like:
This is then used on your observables like: