所以我在整个应用程序中使用Ember #each并且我没有遇到任何问题。但我现在遇到的问题是数组中的最后一项没有正确输出。
<select id="services" size="10" class="services-list">
{{#each sortedModel as |service index|}}
<option {{action 'select' service}}>
{{service.physicalName}} {{index}}
</option>
{{/each}}
</select>
这将在数组中输出0-9但不输出第11项。这是我的JSON对象,我将其作为排序模型返回。
[
{
"physicalName": "service1",
"logicalName": "service 1"
},
{
"physicalName": "service2",
"logicalName": "service 2"
},
{
"physicalName": "service3",
"logicalName": "service 3"
},
{
"physicalName": "service5",
"logicalName": "service 5"
},
{
"physicalName": "service6",
"logicalName": "service 6"
},
{
"physicalName": "service7",
"logicalName": "service 7"
},
{
"physicalName": "service8",
"logicalName": "service 8"
},
{
"physicalName": "service9",
"logicalName": "service 9"
},
{
"physicalName": "service10",
"logicalName": "service 10"
},
{
"physicalName": "service11",
"logicalName": "service 11"
},
{
"physicalName": "service12",
"logicalName": "service 12"
}
]
但是现在出现的是:
答案 0 :(得分:1)
正如@Pavol在评论中提到的那样,我无意中将选择大小设置为10因此显示只有10
更改
<select id="services" size="10" class="services-list">
到
<select id="services" size={{model.length}} class="services-list">
修复了问题