Wrong select-choice highlighted on load
When my app loads for first time I am having an issue with the wrong select choice being highlighted in the drop down. The value is correct in my inspector and the select-match shows the correct choice. but the drop down for some reason is highlighting the wrong one.
Once the app has loaded and you change choices the correct one is highlighted. This only happens on first load.
Anyone ever experience this?


I don't think there is enough information to help here, verify that your ngModel value is set correctly. Can you create a plunkr or similar to reproduce? Maybe that will help.
The ngModel is set correctly because the select-match is correct. Not very good with plunkr :( Below is the relevant code.
<ui-select on-select="app.changed($select)" ng-model="selectedClient">
<ui-select-match>{{$select.selected.name}}</ui-select-match>
<ui-select-choices repeat="client in app.clients | filter: {name: $select.search}">
<span ng-bind-html="client.name | highlight: $select.search"></span>
</ui-select-choices>
</ui-select>
var app = this;
app.user = user.data;
app.clients = clients.data;
app.setClient = function(){
if (!store.get('selectedClient')) {
store.set('selectedClient', clients.data[0]);
};
$rootScope.selectedClient = store.get('selectedClient')
};
app.setClient();
app.logout = function () {
AuthService.logout();
};
app.changed = function ($select) {
$rootScope.selectedClient = $select.selected;
store.set('selectedClient', $select.selected);
$rootScope.$broadcast('client-changed');
};
You need to fix your ngModel reference first. See https://github.com/angular-ui/ui-select/issues/1353#issuecomment-175729671 and FAQ
But if the ngModel was messed up wouldn't {{$select.selected.name}} return the wrong value?
Never mind. I get it now. selectedClient is an object not an item in array. so it doesn't know which item in the array to select
Just to update incase anyone else gets stumped by this. @user378230 Thanks for the help!
<ui-select on-select="app.changed($select)" ng-model="app.selected.item">
<ui-select-match>{{$select.selected.name}}</ui-select-match>
<ui-select-choices repeat="client in app.clients | filter: {name: $select.search}">
<span ng-bind-html="client.name | highlight: $select.search"></span>
</ui-select-choices>
</ui-select>
var app = this;
app.user = user.data;
app.clients = clients.data;
app.setClient = function(){
if (!store.get('selectedClient')) {
store.set('selectedClient', clients.data[0]);
};
$rootScope.selectedClient = store.get('selectedClient');
app.item = $filter('filter')(app.clients, function (d) {return d.id === $rootScope.selectedClient.id;})[0];
app.selected = { item: app.item };
};
app.setClient();
app.logout = function () {
AuthService.logout();
};
app.changed = function ($select) {
$rootScope.selectedClient = $select.selected;
store.set('selectedClient', $select.selected);
$rootScope.$broadcast('client-changed');
};