使用 ng-model 实时应用过滤器 Angular
Applying a filter with ng-model realtime Angular
我有一个这样的输入标签
<input currency type="text" class="form-control amount" ng-model="loan.total">
我想做的是我想将此 "total" 值查看为 3 乘 3(4000 -> 4 000)。loan.total 值应为 4000。但它应该是可见的作为 4 000。尝试应用指令但没有成功。
有什么简单的方法可以做到这一点吗?
您可以像这样在输入之外显示一个值作为货币:
<input type="number" class="form-control amount" ng-model="loan.total"> {{loan.total | currency}}
听起来您想要的是输入掩码。
也许试试这个:
https://github.com/assisrafael/angular-input-masks
它有一个 ui-money-mask 指令。
例如:
确保包含脚本标签并添加模块依赖项:
<script src="angular-input-masks-standalone.min.js"></script>
<script>
angular.module('yourAppName', ['ui.utils.masks']);
</script>
我有一个这样的输入标签
<input currency type="text" class="form-control amount" ng-model="loan.total">
我想做的是我想将此 "total" 值查看为 3 乘 3(4000 -> 4 000)。loan.total 值应为 4000。但它应该是可见的作为 4 000。尝试应用指令但没有成功。
有什么简单的方法可以做到这一点吗?
您可以像这样在输入之外显示一个值作为货币:
<input type="number" class="form-control amount" ng-model="loan.total"> {{loan.total | currency}}
听起来您想要的是输入掩码。
也许试试这个:
https://github.com/assisrafael/angular-input-masks
它有一个 ui-money-mask 指令。
例如:
确保包含脚本标签并添加模块依赖项:
<script src="angular-input-masks-standalone.min.js"></script>
<script>
angular.module('yourAppName', ['ui.utils.masks']);
</script>