簡體   English   中英

ng-repeat可以基於規則顯示數據嗎? *過濾*

[英]Can ng-repeat displays data based on a rule? *filter*

我有兩個選擇(多選/選擇列表)。

我需要在兩邊都顯示客戶端,但是:

  • 左側的選擇列表應僅在“ cliente”表中顯示具有“ consultaNotasDestinadasAutomaticamente”字段為true的客戶端。

  • 右側的選擇列表應僅在“ cliente”表中顯示具有“ consultaNotasDestinadasAutomaticamente”字段為false的客戶端。

我怎樣才能做到這一點?

這是我的html:

   <div class="form group">
         <label class="control-label col-md-3">Empresas:</label>
         <select id="select1" name="select1" multiple="multiple">
             <option ng-repeat="c in clientes" value="{{c.idCliente}}" ng-click="atribuirUm($index, c)">{{c.razaoSocial}}</option>                            
         </select>
         <label class="control-label col-md-3">Empresas:</label>
         <select ng-model="listaEmpresas" id="select2" name="select2" multiple="multiple">
             <option selected="selected" ng-repeat="c2 in clientes2" value="{{c2.idCliente}}" ng-click="limparUm($index, c2)">{{c2.razaoSocial}}</option>                              
         </select>                               
   </div>

您可以使用管道| 將數據傳遞到過濾器

ng-repeat="c in clients | filter:{consultaNotasDestinadasAutomaticamente: true}"

實際上,您可以根據需要通過管道傳遞任意數量的內置過濾器和自定義過濾器,即

ng-repeat="c in clients | filter:{consultaNotasDestinadasAutomaticamente: true} | limitTo:4 | json"

篩選器文檔: https : //docs.angularjs.org/api/ng/filter

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM