我目前有一个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工作,但另外两个不工作。我刚刚更新了问题以显示切换结构。 –