如何将价值转换为印度卢比格式?
how to convert value into Indian rupees format?
我正在从数组中获取值,我需要将该值转换为印度卢比格式吗?
<h3>
<ion-icon ios="ios-cash" md="md-cash"></ion-icon>{{user.members}} / ₹ {{user.total | currency:"₹":0}}
</h3>
预计
我需要的值为 1,95,445.76,
实际产量
195,445.76
根据 documentation,你应该改用这个:
{{user.total | currency: 'INR'}}
我认为你上面使用的格式是 AngularJS (Angular 1.x).
编辑:我注意到上面的格式没有考虑印度数字系统。因此,这是我更新的解决方案。我编写了一个使用 JavaScript 的 .toLocaleString() 的自定义方法。
indianRupeeFormat(val: number) {
return Number(val).toLocaleString('en-IN');
}
这就是它在您的视图中的显示方式:
<p>Rupee:₹ {{ indianRupeeFormat(195445.76) }}</p>
使用内置管道
<h3 <ion-icon ios="ios-cash" md="md-cash"></ion-icon>{{user.members}} / ₹ {{user.total | currency:"INR":0}}
我正在从数组中获取值,我需要将该值转换为印度卢比格式吗?
<h3>
<ion-icon ios="ios-cash" md="md-cash"></ion-icon>{{user.members}} / ₹ {{user.total | currency:"₹":0}}
</h3>
预计 我需要的值为 1,95,445.76, 实际产量 195,445.76
根据 documentation,你应该改用这个:
{{user.total | currency: 'INR'}}
我认为你上面使用的格式是 AngularJS (Angular 1.x).
编辑:我注意到上面的格式没有考虑印度数字系统。因此,这是我更新的解决方案。我编写了一个使用 JavaScript 的 .toLocaleString() 的自定义方法。
indianRupeeFormat(val: number) {
return Number(val).toLocaleString('en-IN');
}
这就是它在您的视图中的显示方式:
<p>Rupee:₹ {{ indianRupeeFormat(195445.76) }}</p>
使用内置管道
<h3 <ion-icon ios="ios-cash" md="md-cash"></ion-icon>{{user.members}} / ₹ {{user.total | currency:"INR":0}}