0

我在这里做错了什么,Angular(1.1.5)没有在这个分组选择下拉列表中正确选择正确的值?

HTML:<select ng-model="options.metricId" ng-options="answer.id as answer.name group by answer.question for answer in options.answers track by answer.id"></select>

options.metricId由控制器正确设置。

options.answers对象如下所示: {id: 8, name: "Leads Others", question: "Assessment"}

所有选项都出现了,但它没有answer.id == options.metricId像我期望的那样选择值。

4

1 回答 1

0

添加parseInt(answer.id)到轨道表达式解决了这个问题。

<select class="form-control" ng-model="options.metricId" ng-options="answer.id as answer.name group by answer.question for answer in options.answers track by parseInt(answer.id)" ng-change="events.updateMetrics()"></select>
于 2014-09-26T16:50:05.977 回答