Hacker Hacker - 1 year ago 69
AngularJS Question

track by not working on select change value not getting selected

I have written code like below

<select ng-model="selectedseasId" ng-options="seas.seasInternalId as seas.seasName for seas in seass track by seas.seasInternalId"> </select>

$scope.selectedseasId = 3;

I have data like

var seass = [ {
"seasInternalId" : 4,
"seasName": "My Second seas"
"seasInternalId" : 3,
"seasName": "My Second seas"

No value is getting selected in select box. Is there anything wrong with my code?

Answer Source

ng-options track by and select as are not compatible. See this link

Surely you don't need the track by ID as I suppose seasInternalId is unique, so seas.seasInternalId as seas.seasName for seas in seass should suffice and work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download