AngularJS(v1.4.0-rc.1) filter 从数组项中选择一个子集
<!doctype html> <html ng-app="dynamicTemplate"> <head> <script src="jslib/angular.js"></script> <script type="text/javascript"> angular.module(‘dynamicTemplate‘, []).controller(‘PhoneListCtrl‘,function($scope) { $scope.phones = [ { "name": "Nexus S", "snippet": "Fast just got faster with Nexus S." }, { "name": "Motorola XOOM with Wi-Fi", "snippet": "The Next, Next Generation tablet." }, { "name": "MOTOROLA XOOM", "snippet": "The Next, Next Generation tablet." } ]; }); </script> </head> <body> Search: <input ng-model="query"> <div ng-controller="PhoneListCtrl"> <ul> <li ng-repeat="phone in phones|filter:query"> {{phone.name}} <p>{{phone.snippet}}</p> </li> </ul> </div> </body> </html>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。