Socket
Socket
Sign inDemoInstall

knockout.decimal

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

knockout.decimal

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


Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

#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

Keywords

FAQs

Package last updated on 11 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc