Rumah  >  Soal Jawab  >  teks badan

angular.js - angular filter问题

下面是angular官网上讲解filter的代码,有些地方没看懂,辛苦各位大神赐教了。

<p ng-init="friends = [{name:'John', phone:'555-1276'},
                         {name:'Mary', phone:'800-BIG-MARY'},
                         {name:'Mike', phone:'555-4321'},
                         {name:'Adam', phone:'555-5678'},
                         {name:'Julie', phone:'555-8765'},
                         {name:'Juliette', phone:'555-5678'}]"></p>

Search: <input ng-model="searchText">
<table id="searchTextResults">
  <tr><th>Name</th><th>Phone</th></tr>
  <tr ng-repeat="friend in friends | filter:searchText">
    <td>{{friend.name}}</td>
    <td>{{friend.phone}}</td>
  </tr>
</table>
<hr>
Any: <input ng-model="search.$"> <br>
Name only <input ng-model="search.name"><br>
Phone only <input ng-model="search.phone"><br>
Equality <input type="checkbox" ng-model="strict"><br>
<table id="searchObjResults">
  <tr><th>Name</th><th>Phone</th></tr>
  <tr ng-repeat="friendObj in friends | filter:search:strict">
    <td>{{friendObj.name}}</td>
    <td>{{friendObj.phone}}</td>
  </tr>
</table>

界面显示效果:


当勾选Equality时,下面的内容不会显示出来


代码中对应的是

不明白它的filter:search:strict是怎么起作用的?为什么什么都不能显示了?

黄舟黄舟2686 hari yang lalu695

membalas semua(1)saya akan balas

  • 淡淡烟草味

    淡淡烟草味2017-05-15 17:15:27

    Kotak semak berguna apabila ditanda, ia adalah benar, yang bermaksud perbandingan yang ketat, yang bermaksud anda perlu memasukkan perkara yang sama untuk menapisnya Anda boleh cuba memasukkan John dalam Nama sahaja dan ia akan ditapis.

    balas
    0
  • Batalbalas