angularjs过滤器--filter与ng-repeat配合有奇效
时间:2022-10-28 09:54:20|栏目:AngularJS|点击: 次
index.html
<!DOCTYPE html> <html> <head> <link href="bootstrap.min.css" rel="external nofollow" rel="stylesheet"> </head> <body ng-app="myApp" ng-controller="myCtrl"> <input type="text" placeholder="请输入学校ID 或 名称" ng-model="query"> <table class="table-bordered"> <tr ng-repeat="school in schoolList | <strong>filter:query</strong>" > <td class="col-md-2">{{ school.schoolId}}</td> <td class="col-md-2">{{ school.schoolName}}</td> </tr> <script src="bootstrap.min.js"></script> <script src="angular.min.js"></script> <script src="script.js"></script> </table> </body> </html>
script.js
angular.module('myApp', []) .controller('myCtrl', function ($scope) { $scope.schoolList = [ { schoolId: 01, schoolName: '中山大学', }, { schoolId: 02, schoolName: '厦门大学', }, { schoolId: 03, schoolName: '北京大学', }, { schoolId: 04, schoolName: '复旦大学', } ]; });
栏 目:AngularJS
下一篇:没有了
本文标题:angularjs过滤器--filter与ng-repeat配合有奇效
本文地址:http://www.codeinn.net/misctech/217553.html