gpt4 book ai didi

javascript - 打破小数位的 Angular 绑定(bind)

转载 作者:行者123 更新时间:2023-11-29 17:13:23 24 4
gpt4 key购买 nike

在我的 $scope 中,我有 tobing= 2.00 或 tobind=2.20 并且我将它绑定(bind)到

  <span >{{datasource.tobind}}</span>

我希望我的绑定(bind)显示文本始终为“2.00”或“2.20”以及最后两位数字,但 Angular 似乎是自动四舍五入。将其设置为文本并将其绑定(bind)为字符串是一种解决方法,但会导致很多地方有逻辑将其转换为数字,然后转换为字符串,这让兔子哭了。请建议如何修复自动舍入。

最佳答案

检查 number filtercurrency filter .

<span >{{datasource.tobind | number:2}}</span>

或:

<span >{{datasource.tobind | currency}}</span>

关于javascript - 打破小数位的 Angular 绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20001954/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com