angularjs过滤器--filter与ng-repeat配合有奇效
程序员文章站
2022-11-20 10:08:01
index.html
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: '复旦大学', } ]; });
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持!
上一篇: 淘宝网开店教程,让你1天学会开网店