Javascript 基于索引的AngularJS滤波器阵列
我有一个数组,比如Javascript 基于索引的AngularJS滤波器阵列,javascript,jquery,angularjs,Javascript,Jquery,Angularjs,我有一个数组,比如 $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
$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/>
{{项目[2]}
如何过滤每个数组的第3个元素并应用适当的过滤器?我很确定我上面的答案是错的。好吧,假设你希望你的输出是
3,c,3,那么你就不需要过滤器了。您只需通过将ng repeat更改为ng选项即可
关于myList[scopeVar]
中的项,请使用$scope.scopeVar=2更改控制器中的索引。请阅读select上的文档。这样创建它可能会有问题。我对你试图让你的输出看起来像什么感到困惑。你是说你想看三,三,三?
<select ng-options="item[2] as item[2] for item in myList"></select>
<select ng-options="item as item for item in myList[2]"></select>