JSPM

knockout.decimal

2.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q15622F
  • License MIT

Simple knockout extender that wraps accounting.js to format and coerce decimal values.

Package Exports

  • knockout.decimal

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (knockout.decimal) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

#Knockout Decimal Extender

A simple knockout extender for decimals that wraps accounting.js.

##Install with Bower

bower install knockout-decimal

Then add knockout.decimal.js to your project.

##How to Use

Include the script on your page (either via a normal script tag or via an AMD loader). Then use it like so:

var dec = ko.observable().extend({ decimal: true });
dec("17000");

console.log(dec()); //17000
console.log(dec.formatted()); //17,000.00

You can also use it to set formatted decimal as a value. This is useful for binding user-editable text boxes to the formatted computed.

dec.formatted("17,000.56");
console.log(dec()); //17000.56