角浮点数分数下来分数、浮点数

2023-09-13 03:48:12 作者:我命由我不由天,

如何与角度考虑带过滤器没有拿到分数多少?我的意思是像1.777我想输出1(角使得这2)如何全面浮点数下来!myvalue的是1.777myvalue的|数量:0结果输出将是2如何进行的:1?

how get number with no fraction in angular in view with filter? i mean like 1.777 i want to output 1 (angular makes that 2) how round float number down! myvalue is 1.777 myvalue| number:0 the output will be 2 how approach to 1?

像parseInt函数jQuery中,我需要考虑????有过滤器角的!

something like parseInt in jquery i need in view???? is there filter in angular that !

推荐答案

这应该是简单的 {{number_ex pression |编号:fractionSize}}

标记

<h6>flight duration:   {{item.travelTime | number: 0}}</h6></div>

看 号码过滤器API

更新

有关决策的轮数,那么你需要使用数量过滤器自定义过滤器内。

For making round number then you need to use number filter inside your custom filter.

标记

<h6>flight duration:   {{item.travelTime | numberFormat: 0}}</h6></div>

过滤器

app.filter('numberFormat', function($filter){
   return function(value, fractionSize){
      if(value){
         $filter('number')(Math.round(value), fractionSize)
      }
   }
})