![](/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.