angularjsangularjs-filterangularjs-templates

Dollars to Cents in AngularJS for Stripe Checkout


So I have a value that is returned from Firebase that looks like this:

143.418

When I run it through angulars currency filter it returns:

{{invoice.pricing.graTotal | currency}}

//Returns : $143.42

I have integrated Stripe Checkout into my application and it needs values to look like so:

14342

So Without the decimal points or dollar signs. Not formatted at all. So how would I get the original value rounded and then remove the decimal point to be sent to stripe?

I tried adding variables to the formatter:

{{invoice.pricing.graTotal | currency:undefined:0}}

But that added the dollar sign and removed the cents all together.

$143

Solution

  • Simply define a filter that uses

    Math.round(amount * 100);