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

前提是你 提交于 2019-12-22 10:57:19

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/18028378/how-do-you-iterate-over-an-array-of-objects-for-typeahead

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!