I am trying to set China as selected country but somehow it is only setting China in dropdown if I am doing like - $scope.countrySelected = $scope.countryList[5];
Let me know if it is possible to set value by text only as through Service I am getting China as a text only which I need to match.
HTML Code -
<select
ng-options="country.c_name for country in countryList track by country.c_id"
ng-model="countrySelected">
</select>
SCRIPT CODE -
var myApp = angular.module('myApp', []);
myApp.controller('mainCtrl', function($scope){
$scope.countryList = [
{c_id: 1, c_name: 'Iran'},
{c_id: 2, c_name: 'Iraq'},
{c_id: 3, c_name: 'Pakistan'},
{c_id: 4, c_name: 'Somalia'},
{c_id: 5, c_name: 'Libya'},
{c_id: 6, c_name: 'China'},
{c_id: 7, c_name: 'Palestine'}
];
$scope.countrySelected = 'China';
})
Working Plnkr - http://plnkr.co/edit/6qSvuuOtJHVSoNWah0KR?p=preview