<!DOCTYPE html> <html> <head> <link href="https://www.jb51.net/bootstrap.min.css"> </head> <body ng-app="myApp" ng-controller="myCtrl"> <input type="text" placeholder="请输入学校ID 或 名称" ng-model="query"> <table> <tr ng-repeat="school in schoolList | <strong>filter:query</strong>" > <td>{{ school.schoolId}}</td> <td>{{ school.schoolName}}</td> </tr> <script src="https://www.jb51.net/bootstrap.min.js"></script> <script src="https://www.jb51.net/angular.min.js"></script> <script src="https://www.jb51.net/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: '复旦大学', } ]; });