Instead of setting the ng-model to item.size.code, how about setting it to size:
<select ng-options="size as size.name for size in sizes"
ng-model="item" ng-change="update()"></select>
Then in your update()
method, $scope.item
will be set to the currently selected item.
And whatever code needed item.size.code
, can get that property via $scope.item.code
.
Update based on more info in comments:
Use some other $scope property for your select ng-model then:
<select ng-options="size as size.name for size in sizes"
ng-model="selectedItem" ng-change="update()"></select>
Controller:
$scope.update = function() {
$scope.item.size.code = $scope.selectedItem.code
// use $scope.selectedItem.code and $scope.selectedItem.name here
// for other stuff ...
}
~ Answered on 2013-01-17 19:50:50