angular-currency-filter

WebJar for angular-currency-filter

License

License

MIT
Categories

Categories

Angular User Interface Web Frameworks
GroupId

GroupId

org.webjars.bower
ArtifactId

ArtifactId

angular-currency-filter
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

angular-currency-filter
WebJar for angular-currency-filter
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/Zmetser/angular-currency-filter

Download angular-currency-filter

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.bower/angular-currency-filter/ -->
<dependency>
    <groupId>org.webjars.bower</groupId>
    <artifactId>angular-currency-filter</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.bower/angular-currency-filter/
implementation 'org.webjars.bower:angular-currency-filter:1.0.2'
// https://jarcasting.com/artifacts/org.webjars.bower/angular-currency-filter/
implementation ("org.webjars.bower:angular-currency-filter:1.0.2")
'org.webjars.bower:angular-currency-filter:jar:1.0.2'
<dependency org="org.webjars.bower" name="angular-currency-filter" rev="1.0.2">
  <artifact name="angular-currency-filter" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.bower', module='angular-currency-filter', version='1.0.2')
)
libraryDependencies += "org.webjars.bower" % "angular-currency-filter" % "1.0.2"
[org.webjars.bower/angular-currency-filter "1.0.2"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

Angular Currency Filter

Build Status

Extend angular's built in currency filter.

Description

Formats a number as a currency (ie $1,234.56 or 914.3534€). When no currency symbol is provided, default symbol for current locale is used.

Usage

Overwrites angular's default currency filter if module: currencyFilter is injected. (complete example in the Example section)

In HTML Template Binding

{{ currency_expression | currency:symbol[:fractionSize[:suffixSymbol[:customFormat]]] }}

In JavaScript

$filter('currency')(amount, symbol[, fractionSize[, suffixSymbol[, customFormat]]])

Paramaters

Param Type Details
amount number Input to filter.
symbol string Currency symbol or identifier to be displayed. Falls back to ng.$locale.
fractionSize number Number of decimal places to round the number to. Falls back to ng.$locale
suffixSymbol boolean or string If set to true the currency symbol will be placed after the amount. If passed as a string, will apply currencySymbol as a prefix and suffixSymbol as a suffix
customFormat object Customize group and decimal separators (GROUP_SEP, DECIMAL_SEP) Both falls back to ng.$locale.

Returns

String: Formatted number.

Use cases

var formats = {
  GROUP_SEP: ' ',
  DECIMAL_SEP: ','
};

// With all parameters
expect(currency(1234.4239, '€', 1, true, formats)).toEqual('1 234,4€');

// With all parameters, using string suffix
expect(currency(1234.4239, '€', 1, 'EUR', formats)).toEqual('€1 234,4EUR');

// With missing fraction size
expect(currency(1234.4239, '€', true)).toEqual('1,234.42€');

// With missing fraction size, using string suffix
expect(currency(1234.4239, '€', 'EUR')).toEqual('€1,234.42EUR');

// With fraction size only
expect(currency(1234.4239, '$', 3)).toEqual('$1,234.424');

// Only with symbol
expect(currency(1234.4239, '$')).toEqual('$1,234.42');

// Only with custom group and decimal separators
expect(currency(1234.4239, formats)).toEqual('$1 234,42');

Example

HTML Template Binding

<span ng-bind="price | currency:'€':true"></span> <!-- 1234.42€ -->
<span ng-bind="price | currency:'$':' USD'"></span> <!-- $1234.42 USD -->

JavaScript

angular.module('app', ['currencyFilter']).
    controller('Ctrl', function ( $scope, $filter ) {
        var currency = $filter('currency');
        $scope.price = currency(1234.4239, '€', 0, true); // 1234€
        $scope.price = currency(1234.4239, '$', 0, ' USD'); // $1234 USD
    });

Install

Via bower

bower install --save angular-currency-filter

Include src/currency-filter.js or dist/currency-filter.min.js to your project.

<script src="/bower_components/angular-currency-filter/dist/currency-filter.min.js"></script>

Don't forget to add currencyFilter module to your app's dependecies.

Test && Build

$ npm install
$ bower install

Test

$ grunt test

Build

$ grunt build

Compatibility

Functionality verified with unit test with angular versions from v1.2.1 to v1.4.9.

Versions

Version
1.0.2