![](/img/trans.png)
[英]How to filter by a property 'today' in ng-repeat using angularjs?
[英]AngularJS filter by property using Ng-Repeat NOT working
我有一個ng-repeat,它成功地重復數據。 現在,我想通過輸入框中輸入的屬性來過濾結果。 然而,它要么根本不起作用,要么如果我嘗試各種各樣的東西,有時候什么都沒有顯示出來。 正如你所看到的那樣,這是一項正在進行中的工作,我已經嘗試了很多不同的東西:因此為什么我的代碼不一致! 請不要對此發表評論,因為它不具有建設性!
<tr ng-if="vm.detail == true">
<th><input type="text" ng-model="filter.TrusteeCustNum" /></th>
<th><input type="text" ng-model="filter.MchNumber" maxlength="4" class="input- sm form-control" /></th>
<th><input type="text" ng-model="filter.ContractNumber" class="input-sm form-control" /></th>
<th><input type="text" ng-model="vm.PlanCode" maxlength="10" class="input-sm form-control" /></th>
<th><input type="date" ng-model="filter.PlanStatusDate" /></th>
<th><input type="text" ng-model="filter.PlanStatus" /></th>
<th><input type="date" ng-model="filter.PlanEffectiveDate" /></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="plan in vm.PlanCodeInfo | filter: vm.PlanCode | orderBy: vm.PlanCode" ng-if='vm.detail == true && vm.detailPlanCode'>
<td> {{plan.TrusteeCustNum}}</td>
<td>{{plan.CustomerNumber}}</td>
<td>{{plan.ContractNumber}}</td>
<td>{{plan.PlanCode }}</td>
<td>{{plan.PlanStatusDate | date: 'yyyy-MM-dd'}}</td>
<td>{{plan.PlanStatus}}</td>
<td> {{plan.PlanEffectiveDate | date: 'yyyy-MM-dd'}}</td>
<td><a href="">Rates</a></td>
<td><a href="">State Availability</a></td>
</tr>
我如何獲得任何過濾器來過濾我正在使用的屬性的結果,並按這些屬性對它們進行排序?
如果PlanCode
屬性PlanCode
進行過濾,則filter應該是具有指定屬性的對象:
ng-repeat="plan in vm.PlanCodeInfo | filter:filterObj"
在HTML中,您可以使用相應的ngModel
定義過濾器輸入。 當然,您可以使用多個屬性進行篩選。 以下是PlanCode
和PlanStatusDate
過濾器的示例:
<input type="text" ng-model="filterObj.PlanCode">
<input type="text" ng-model="filterObj.PlanStatusDate">
你的$ scope中是否存在vm.PlanCode? 您是否嘗試使用“planCode”這樣的簡單名稱替換它並添加$ scope.planCode =''; 你的美元范圍?
只是為了看看它是否有所作為?
查看您的模型/范圍會很有幫助。
filter:filter.PlanCode是我需要通過planCode過濾的代碼。 此外,我必須將ng-model更改為filter.PlanCode。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.