Reputation: 3272
In my controller I set this up to $scope:
$scope.item = Item.getByID(id);
$scope.destination = Destination.getList();
The template is implemented like this:
<select ng-model="item.destination" ng-options="item.name for item in destination">
The item:
{name:"name", id:1, destination:{name:"name", url:"url"}}
The destination:
[{name:"name1", url:"url1"},{name:"name2", url:"url2"},{name:"name3", url:"url"3}]
I receive the item and the destination from the localStorage. After I choose a destination in the option-list, it updates the item (ng-model). Then I store it in the localStorage. That works as long as I don't close the application. After a app-restart, the item.destination is stored correct, and the destination list didn't change. Both scope.item and scope.destination have the correct items. But the template doesn't set the ng-module as selected.
Upvotes: 0
Views: 82
Reputation: 52847
Bind your select field to the item model:
<select ng-model="item" ng-options="item as item.name for item in destination">
Upvotes: 2