首页 > 其他 > 详细

Angular引入百分比过滤器

时间:2015-10-26 12:18:49      阅读:370      评论:0      收藏:0      [点我收藏+]

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引入百分比过滤器

原文:http://my.oschina.net/u/2351685/blog/522026

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!