我有使用角度的html頁面。ng-model返回值的名稱代替實際值
我有陣列納克重複的表:
<tr ng-repeat="oblig in Obligations">
oblig
對象包含連接到另一陣列ChargeOptions
的chargeOptionId
屬性。
在表格內部有一個select
元素,我想要顯示收費選項oblig
的詳細信息。
的html代碼:
<select class="form-control full-width" ng-model="oblig.ChargeOptionId">
<option ng-selected="ch.Id == oblig.ChargeOptionId" value="ch.Id" ng-repeat="ch in ChargeOptions">{{ch.Account}}</option>
</select>
的select
元素顯示充電選項的細節,因爲我想要的,但是當我嘗試保存oblig
,到位的ch.Id
價值oblig.ChargeOptionId="ch.Id"
字符串。
我嘗試:使用ng-value
1),但在選擇顯示不正確的數據。
2)ng-options
,但仍然數據顯示不正確。
我該如何解決這個問題?
您可以發佈您'oblig' JSON? – Nishant123
提供完整的代碼。這不清楚。 – Deadpool
當我將它改爲value =「{{ch.Id}}」或ng-value =「ch」時,您應該查看NgOption屬性https://docs.angularjs.org/api/ng/directive/ngOptions –