i am unable to change selected values inside select2 in my controller.
<select id="drptabselect" ng-model="selectedTab" class="form-control select2"
ng-options="x.Title for x in tabnames">
</select>
i have ajax call where data.Tab returning as follow
$scope.selectedTab = data.Tab;
ajax tab result as below
"Tab": {
"$id": "2",
"ID": 4,
"Title": "FirstTab"
},
if i try to print the
<span>{{selectedTab}}</span>
it gives expected value after assignmnet as
{"$id": "2","ID": "4","Title": "FirstTab"}
Unfortunatly the same not applied to select2 dropdown. there it still shows last selected value. How can populate the value in dropdown box too?
my $scope.tabnames looks like this
[{"$id": "1",
"ID": 4,
"Title": "FirstTab"
},
{"$id": "2",
"ID": 5,
"Title": "Secondtab"
},
{"$id": "3",
"ID": 6,
"Title": "Thirdtab"
}]
i am using regular select2 library (not angualr-ui)