亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

angularJs使用$watch和$filter過濾器制作搜索篩選實(shí)例

 更新時間:2017年06月01日 09:01:15   作者:泠泠在路上  
本篇文章主要介紹了angularJs使用$watch和$filter過濾器制作搜索篩選實(shí)例,具有一定的參考價值,感興趣的小伙伴們可以參考一下

整理文檔,搜刮出一個angularJs使用$watch和$filter過濾器制作搜索篩選,稍微整理精簡一下做下分享。

<div ng-app="module" ng-controller="ctrl">
  搜索: <input type="text" ng-model="search">
  <table border="1" width="600">
    <tr>
      <td>編號</td>
      <td>點(diǎn)擊數(shù)</td>
      <td>標(biāo)題</td>
    </tr>
    <tr ng-repeat="(k,v) in lists">
      <td>{{v.id}}</td>
      <td>{{v.click}}</td>
      <td>{{v.title}}</td>
    </tr>
  </table>
</div>
<script>
  var m = angular.module('module', []);
  m.controller('ctrl', ['$scope', '$filter', function ($scope, $filter) {
    $scope.data = [
      {id: 1, click: 100, title: '百度'},
      {id: 2, click: 200, title: '騰訊'},
      {id: 3, click: 300, title: '谷歌'},
    ];
    //臨時數(shù)據(jù)用于顯示
    $scope.lists = $scope.data;
    $scope.$watch('search',function(n,o){
      $scope.lists = $filter('filter')($scope.data,n);
    });
  }]);
</script>

效果圖:

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論