angular-currency-filter

WebJar for angular-currency-filter

Лицензия

Лицензия

MIT
Категории

Категории

Angular Взаимодействие с пользователем Веб-фреймворки
Группа

Группа

org.webjars.bower
Идентификатор

Идентификатор

angular-currency-filter
Последняя версия

Последняя версия

1.0.2
Дата

Дата

Тип

Тип

jar
Описание

Описание

angular-currency-filter
WebJar for angular-currency-filter
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

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

Скачать angular-currency-filter

Как подключить последнюю версию

<!-- 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"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

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.

Версии библиотеки

Версия
1.0.2