Angular 2 - how round calculated number?

后端 未结 3 1893
一个人的身影
一个人的身影 2021-01-12 05:37

I have a *ngFor loop and want to calculate a value - with 2 decimal places.

The calculation works:

3条回答
  •  时光取名叫无心
    2021-01-12 06:12

    You need another pipe to do this

    import {Pipe} from 'angular2/core';
    
    @Pipe({name: 'round'})
    export class RoundPipe {
      transform (input:number) {
        return Math.floor(input);
      }
    }
    

    template:

    {{ date | amDifference : item.startdate : 'minutes' : true | round }}
    

提交回复
热议问题