View on GitHub

js-snippets

Helpful snippets for JavaScript

Download this project as a .zip file Download this project as a tar.gz file

Knockout: Number Formatting Binding

A simple example of how to add a number formatting binding to a knockout.js app
Get the code here!

Default:
<span data-bind="number: myNumber"></span>
					
3 Decimal Places:
<span data-bind="number: myNumber, precision: 3"></span>
					
US Dollars:
<span data-bind="number: myNumber, precision: 2, symbol: '$ '"></span>
					
Euros UK:
<span data-bind="number: myNumber, precision: 2, symbol: '&euro; ', decimal: ','"></span>
					
Euros Spain:
<span data-bind="number: myNumber , precision: 2, symbol: ' &euro;', decimal: ',', separator: ' ', after: true">