Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

http://plnkr.co/edit/VSA1gVEixxis7utvAoQr?p=preview

I get that "state for state in states" works because it's just an array of Strings. I'd like to loop through an array of objects shown in $scope.state_details in the plnkr.co example.

<input type="text" ng-model="selected" typeahead="state for state in states | filter:$viewValue | limitTo:8">

What's the correct expression to use in the typeahead attr when i have an array of objects like this?...

data = [
  {
    name:"Alabama",
    population:2000
  },
  {
    name:"Alaska",
    population:20000
  },
  {
    name:"California",
    population:200000
  },
];
share|improve this question

If you want the model to be the actual state object and not the name:

typeahead="state as state.name for state in statesdetails"
share|improve this answer

Figured this out!

s.name in s in statedetails
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.