角浮点数分数向下 [英] angular float number fraction down

查看:38
本文介绍了角浮点数分数向下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用过滤器获取角度中没有分数的数字?我的意思是像 1.777我想输出 1(角度使 2)如何圆浮数下来!我的值为 1.777我的价值|数量:0
输出将为 2如何接近1?

我需要查看 jquery 中的 parseInt 之类的东西????是否有角度过滤器!

解决方案

应该是简单的 {{ number_expression |数字:fractionSize}}

标记

飞行时间:{{item.travelTime |数量:0}}</h6></div>

数字过滤API

更新

为了生成整数,您需要在自定义过滤器中使用 number 过滤器.

标记

飞行时间:{{item.travelTime |数字格式:0}}</h6></div>

过滤

app.filter('numberFormat', function($filter){返回函数(值,分数大小){如果(值){$filter('number')(Math.round(value),fractionSize)}}})

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?

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

解决方案

It should be simply {{ number_expression | number : fractionSize}}

Markup

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

Look at Number filter API

Update

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

Markup

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

Filter

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

这篇关于角浮点数分数向下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆