AngularJS – Format Cents As Monetary Unit (Dollars, Rand etc)

1. Create a filter

app.filter('MonetaryUnit', function () {
    return function (amount) {
        return (amount / 100).toFixed(2);

2. Apply filter to field

{{someField | MonetaryUnit}}

For example, if someField has a value of “2000” it will render as “20.00”.

This entry was posted in Programming and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *