How do you iterate over an array of objects for typeahead?

angular-ui-bootstrap, angularjs

Solution

`state for state in states` is the comprehension expression, short for

angular.forEach(states, function (state) {
    return state;
});

You can take a look at the documentation about the comprehension expression introduced at ngOptions of select directive.

Problem

http://angular-ui.github.io/bootstrap/ I want to use the bootstrap's typeahead, and search two different key-pairs in an object. How do I iterate over an array objects? Also could someone explain what for is this? `typeahead="state for state in states | filter:$viewValue"` The `for` clause is throwing me off and it seems really unclear because `state for state` shares the same name.

Original source