3
ng-modelの中で式を実行する必要があります。ng-modelの式AngularJS
私はリストに示された整数の配列を持ち、各項目のクリックで入力フィールドを生成する必要があります。すべての入力フィールドは、1を底とする比率の生成値を持ちます。ユーザーが値を変更できるので、入力フィールドの数値の合計も取得する必要があります。
マイコードこのため、ユーザーが変更またはどのように私は、各フィールドの値を格納しない場合、私はすべてのフィールドの値の数を取得するにはどうすればよい
<div class="row" ng-repeat="kpi in SelectedKpiModel">
<div class="small-2 columns" ng-click="View.RemoveSelectedKPI($index)" style="margin-top:0.5em;border:ridge;padding-bottom: 1em; padding-top:0.5em; text-align:center"><span class="fa fa-scissors"></span></div>
<div class="small-4 columns" style="margin-top:0.5em;border:ridge;padding-bottom: 1em; padding-top:0.5em; text-align:center">
{{kpi.id}}
</div>
<div class="small-4 columns" style="float:left;margin-top:0.5em;border:ridge; padding:0em">
<input type="number" value="{{1/SelectedKpiModel.length}}" />
</div>
</div>
です必要に応じて検索しますか?
ng-model="{{1/SelectedKpiModel.length}}"
のように試しましたが、エラーが出ました。
ありがとうございました。
<input type="number" ng-model="getLength()" />
とあなたの機能 - -
は私たちにエラーを表示することができますか? あなたの長さが0ならば=> https://en.wikipedia.org/wiki/Division_by_zero –
あなたのコントローラーはどのように見えますか?そして 'ng-model'は双方向バインディングです。上記のような式には使用できません。このようなものが必要な場合は、[getter/setter](https://docs.angularjs.org/api/ng/directive/ngModel)にバインドする必要があります。 – Veluria
私は間違いなしです。私はすべてのフィールドの合計を取得したい。 3つのフィールドまたは5つのフィールドが選択に依存することができます。すべての入力フィールドの値の合計を私に教えてください。 – Joseph