我目前有一個JSON數組,我試圖通過使用循環向屏幕輸出。目前我可以在沒有循環的情況下得到我想要的結果,但是當我嘗試將其轉換爲循環時,我遇到了一些問題。任何見解都會有所幫助。謝謝。角度循環JSON數組
這是我當前的代碼:
<div>
<h2>Document Type</h2>
<select>
<option>Document Type : {{handoff[0].documentType}}</option>
<option>Document Type : {{handoff[1].documentType}}</option>
<option>Document Type : {{handoff[2].documentType}}</option>
<option>Document Type : {{handoff[3].documentType}}</option>
<option>Document Type : {{handoff[4].documentType}}</option>
</select>
<select>
<option ng-repeat="temp in handoff">Document Type : {{temp[0].documentType}}</option>
</select>
<select>
<option ng-repeat="temp in handoff">Document Type : {{temp.documentType}}</option>
</select>
</div>
我的業績爲先「的選擇」是正確的,但第二和第三都沒有結果。
"handoffs":{"0":{ "documentType":"0","conlID":"1230","userName":"CU0","handoff":"h=81878E9E772BCA176D868CA633BFB47D38274B1B209FD80856E56B47"
},"1":{"documentType":"1","conlID":"C010","userName":"A010","handoff":"ERROR: A temporary problem was encountered. Please try your request again in a few minutes."},"3":{"documentType":"3","conlID":"C010","userName":"C10","handoff":"HANDOFF=81878E9E77FB56E56B47"}}
你可以發佈控制器代碼或至少是什麼切換數組看起來像?你也可以澄清你的代碼的哪部分工作,哪部分不工作? – o4ohel
所有的選項都缺少'value'屬性.. 3rd應該是正確的。雖然我建議你去使用'ng-options' –
@ o4ohel:控制器代碼根本沒有幫助,因爲它是一個API響應。第一個SELECT工作,但另外兩個不工作。我剛剛更新了問題以顯示切換結構。 –