这是我的代码
<td><span ng-bind="'$' + (o.Price | number : 2)"></span></td>
在上面的例子中,结果是68.74。
为了使这个数字有意义,我必须将它四舍五入到69
您应该使用Pipe来帮助您完成
import {Pipe} from 'angular2/core';
@Pipe({name: 'roundUp'})
export class RoundPipe {
transform (input:number) {
return Math.round(input);
}
}
所以代码应该像一样
<td><span ng-bind="'$' + (o.Price | roundUp)"></span></td>