使用数字获取“ngModel:nonassign”时ng-model值舍入?

时间:2017-07-21 10:24:44

标签: angularjs

我正在使用ng-model ==“value | number:2”但在控制台中遇到错误。

Error: [ngModel:nonassign] http://errors.angularjs.org/1.5.8/ngModel/nonassign?p0=sumatoriaDeCuotas%20%7C%20number%20%3A%202&p1=%3Cinput%20type%3D%22text%22%20ng-model%3D<input type="text" ng-model="sumatoriaDeCuotas | number : 2" class="no-margin resumedatotabletd1 ng-pristine ng-untouched ng-valid" ng-class="{'errorhilight': sumatoriaDeCuotas < 0}" ng-disabled="mySwitch" disabled="disabled">umatoriaDeCuotas%20%7C%20number%20%3A%202%22%class%3D%22no-margin%20resumedatotabletd1%20ng-pristine%20ng-untouched%20ng-valid%22%20ng-class%3D%22%7B'errorhilight'%3A%sumatoriaDeCuotas%20%3C%200%7D%22%20ng-disabled%3D%22mySwitch%22%20disabled%3D%disabled%22%3E
    at http://localhost:8082/js/commons/angular.min.js:6:412
    at Pg.$$setOptions (http://localhost:8082/js/commons/angular.min.js:282:81)
    at Object.pre (http://localhost:8082/js/commons/angular.min.js:289:300)
    at http://localhost:8082//js/commons/angular.min.js:16:71
    at la (http://localhost:8082/js/commons/angular.min.js:81:90)
    at p (http://localhost:8082/js/commons/angular.min.js:66:149)
    at g (http://localhost:8082/js/commons/angular.min.js:58:481)
    at g (http://localhost:8082/js/commons/angular.min.js:58:498)
    at g (http://localhost:8082/js/commons/angular.min.js:58:498)
    at g (http://localhost:8082/js/commons/angular.min.js:58:498)

1 个答案:

答案 0 :(得分:1)

要缩短它 - 你不能在.bottom-icon { text-align:center; padding-top:30px; } 表达式中使用过滤器。过滤器用于输出格式,ng-model与输入有关。 ng-model表达式应始终作为assign表达式的正常左侧部分。如果你的表达是别的,那么它将会失败。因此,每当您撰写ng-model时,请将其视为ng-model="expression"。在您的情况下,它是expression = $modelValue。这没什么意义。