Hi Jake,
Why you do not initialize the selectedPerson to the right value in the
constructor of your controller ?
*$scope.people = [{'name':'joe', 'age': 24}, {'name':'anna', 'age': 22},
{'name':'sam', 'age': 38}];*
$scope.selectedPerson = $scope.people[2]
Manu
@EmmanuelDemey
2015-10-01 9:17 GMT+02:00 Jake K. <[email protected]>:
> Hello, angular community!
>
> My question is the following:
>
> Can anyone help me how to pre select an element inside a select tag with
> 'ng-options'?.
>
> For example, assume in my controller I have the following:
>
> *// inside controller*
> *$scope.people = [{'name':'joe', 'age': 24}, {'name':'anna', 'age': 22},
> {'name':'sam', 'age': 38}];*
>
> *// end*
>
>
> *// in my view *
>
> *<select ng-model="selectedPerson" ng-options="person.name
> <http://person.name> for person in people"></select>*
> *// end*
>
>
> How would I *pre select 'selectedPerson*' to be say, the last person
> (sam)?
>
>
> Thanks in advance
>
> --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/d/optout.
>
--
Emmanuel DEMEY
Consultant
Zenika
+33 (0)6 47 47 42 02
[email protected]
- fr.linkedin.com/in/emmanueldemey/
Twitter : @EmmanuelDemey
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.