Angular引入百分比过滤器

Installation

Install with Bower:

$ bower install angular-percentage-filter

Usage

Include the library:

<script src="/bower_components/angular-percentage-directive/percentage.js"></script>

Import it to the angular applicaiton:

angular.module('myApp', ['percentage']);

Use it in the view:

<span>{{ 2/3 | percentage:2:"$" }}</span>
<span>{{ 0.2 | percentage }}</span>
<span>{{ (items | filter:{done: true}).length/items.length | percentage }}</span>


可以自定义小数位及百分号格式,比如

2/3 | percentage:2:"$"   --->   33.33$


你可能感兴趣的:(Angular引入百分比过滤器)