我有以下输入:
<input type="text" id="cpfcnpj" ng-model="PersonalIdentificationNumber" ui-mask-placeholder="" ui-mask="000.000.000-00" name="PersonalIdentificationNumber" model-view-value="true" required="" readonly="" class="ng-pristine ng-not-empty ng-valid ng-valid-required ng-touched">
但是当我收到数据来填充输入并将相同的数据应用于 ng-model 时:
$scope.PersonalIdentificationNumber = result.Result.PersonalIdentificationNumber;
掩码格式不正确。我得到的不是 000.000.000-00
,而是 00000000000
。
已经尝试过此解决方案以及: $("#cpfcnpj").attr('mask', '000.000.000-00');
但它们都不起作用。
最佳答案
尝试将掩码设置为:ui-mask="999.999.999-99"
关于javascript - 掩码未应用于 ng-model 的输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46542410/