0

I am using ng-select to put the default option as the first option (past). However it shows the default as "undefined".

<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>

If I do this however I don't get the same error.

<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>

Thing is I need to show a few in the list and a few at the beginning. Is there a way of doing it?

Krzysztof Safjanowski
  • 7,292
  • 3
  • 35
  • 47
Ysrninja
  • 129
  • 1
  • 2
  • 9

2 Answers2

0

Try something like this.

<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.sem in offSemList" value="{{sem.sem}}"> {{sem.sem}} </option>
</select>
Antony
  • 512
  • 2
  • 18
0

I got it. All I did was this:

<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>

Thanks goes to Initializing select with AngularJS and ng-repeat

Community
  • 1
  • 1
Ysrninja
  • 129
  • 1
  • 2
  • 9