嗨我目前正在研究一個AngularJS離子應用程序,但在設置視圖中的模型值時遇到問題。 它是一個定義了字段的簡單表單。如何設置從其他兩個數字字段計算的angularjs模型值
<input type="number" ng-model="form.field1" />
<input type="number" ng-model="form.field2" ng-change="count=form.field1+form.field2" />
<input type="number" ng-model="form.field3" ng-init="form.field3=count" ng-value="count"/>
在第三個字段中,我可以看到顯示的值,但是當提交給服務器時,它具有「0」而不是計數值。
在控制器我有
$scope.form={};
任何幫助表示讚賞,新AngularJS。
你能發佈您的代碼放在這裏,或使用引擎收錄/的jsfiddle等,所以我們可以看到它嗎?謝謝 – rrd
嗨剛發佈。 – Sat
我試過這個方法,但沒有運氣$ scope.count = 0.00; $ scope.addNumbers = function(b1,b2){ if(b1!== null && b2!== null) { $ scope.count = b1 + b2; $ scope.form.Total。$ setViewValue('$ scope.count'); angular.element('#Total')。controller('ngModel')。$ render(); } } – Sat