【AngularJS】过滤数组中的子集(每一个子项都过滤)

说白了就是filter+repeat;


源码:

<!DOCTYPE html>

<html>
<head>
<meta charset="utf-8">
<script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
</head>
<body>
<div ng-app="myApp"ng-controller="namesCtrl">
<p>输入过滤</p>
<p><input type="text" ng-model="test"></p>

<ul>
<li ng-repeat="x in names| filter:test | orderBy:'country'">
{{(x.name|uppercase)+','+x.country}}
</li>
</ul>
</div>


<script src="http://www.runoob.com/try/demo_source/namesController.js"></script>

</body>



注意:

① ng-repeat=" x in  数组":是重复的格式,表示数组中的每一项都重复,一直到完毕;一般结合<ul><li></li></ul>标签使用

| filter 条件:是过滤器格式,

③ | orderBy:'country':表示按照过滤条件排序,过滤的字段用单引号引入;


相关文章:

  • 2021-09-13
  • 2021-12-27
  • 2021-08-30
  • 2021-05-16
  • 2021-07-24
  • 2022-02-18
猜你喜欢
  • 2021-12-06
  • 2022-12-23
  • 2022-02-09
  • 2021-10-24
  • 2021-05-26
  • 2021-08-26
  • 2021-10-30
相关资源
相似解决方案