my angular ng-options directive is not working. The ng-model is not updating while changing the options.
angular snippets
scope.searchoptions = [
{ name: "All", id: 1 },
{
name: "Devices",
id: 2
}, {
name: "Sessions",
id: 3
}, {
name: "Alerts",
id: 4
},{
name: "Files",
id: 5
}];
scope.currentSearch = scope.searchoptions[0]; // Intial object
// Html snipets
<div class="form-group l-h m-a-0">
<select class="form-control"
ng-options="item.name for item in searchoptions track by item.id"
ng-model="currentSearch">
</select>
</div>
The given code is not updating the model while selecting an option
Please note: ng-init failed for me in my specific case. Problem was that the value I was using was not available yet at the time ng-init ran: I got the value via an ajax call and at that moment the ng-init was already finished