你如何遍历的预输入对象的数组?遍历、数组、对象

2023-09-13 04:27:15 作者:柳暗花明又一村姑

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?

也可能有人解释什么是什么?预输入=状态,在状态状态|过滤器:$ viewValue

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.

推荐答案

状态在州是COM prehension前pression,简称

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

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

您可以看看在左右的 ngOptions 选择指令。

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