繁体   English   中英

基于索引的AngularJS过滤器数组

[英]AngularJS Filter Array Based On Index

我有一个数组

$scope.myList = 
[
 ["one","two","three"],
 ["a","b","c"],
 ["one","two","three"]
]

现在,我想使用ng-repeat列出带有过滤器的第三个索引。

<select >
    <option ng-repeat="item in myList| filter:item[2]:'text_here'">
         {{item[2]}} 
    </option>
</select><br/>

我该如何过滤每个数组的第三个元素并应用适当的过滤器? 我很确定上面的答案是错误的。

好吧,假设您希望输出为three,c,three那么您就不需要过滤器了。 您只需要通过http://docs.angularjs.org/api/ng/directive/select将ng-repeat更改为ng-options

<select ng-options="item[2] as item[2] for item in myList"></select>

如果您只想列出$scope.myList第三个数组的索引,则可以这样做

<select ng-options="item as item for item in myList[2]"></select>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM