I'm pulling in an array of objects as $scope.templates
. I'd like to be able to set $scope.item.steps
(my select model name) to the value of template.steps
for the selected option in my ng-options array. Is there an easy way to do this without having add extra controller logic?
<select class="form-control" ng-options="template.name for template in templates" ng-model="item.steps">
Beyers answered it spot on. Just one suggestion would be to use
track by
It doesn't need to be
template.id
but you should track some unique identifier. This helps with a number of performance/rendering issues.Definitely necessary if:
templates
)Related: ng-repeat , ng-options