使用ng-select with和<option ng-repeat =“”> ...使ng-select指向未定义

时间:2015-07-25 08:53:40

标签: angularjs

我使用ng-select将默认选项作为第一个选项(过去)。但是它将默认值显示为“未定义”。

<select ng-model="yearSem" ng-show="integrated" ng-change="enrollCtrl.sendYearAndSem()">
       <option value="Past" ng-selected="true"> Past Semesters </option>
       <option value="Current"> Current Semester </option>
       <option ng-repeat="sem in offSemList" value="{{sem}}"> {{sem}} </option>
</select>

如果我这样做,但我没有得到同样的错误。

<select ng-model="yearSem" ng-show="integrated" ng-change="enrollCtrl.sendYearAndSem()">
       <option value="Past" ng-selected="true"> Past Semesters </option>
       <option value="Current"> Current Semester </option>
</select>

我需要在列表中显示一些,并在开头显示一些。有办法吗?

2 个答案:

答案 0 :(得分:0)

尝试这样的事情。

net stop http

答案 1 :(得分:0)

我明白了。我所做的就是:

<select class="filled" ng-model="yearSem" ng-show="integrated" ng-change="enrollCtrl.sendYearAndSem()">
      <option ng-repeat="sem in offSemList" ng-selected="{{sem == 'Past'}}" value="{{sem}}"> {{sem}} </option>
</select>

感谢Initializing select with AngularJS and ng-repeat