我有一个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>我怎样才能让任何过滤器根据我正在使用的属性过滤结果,并根据这些属性对它们进行排序?
发布于 2014-10-22 22:54:25
如果要按属性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">发布于 2014-10-22 22:26:22
您的$scope中是否存在vm.PlanCode?您是否尝试过将其替换为"planCode“之类的简单名称并将$scope.planCode = '';添加到您的$scope中?
只是想看看会不会有什么不同?
看看你的模型/范围会很有帮助。
发布于 2014-10-22 22:45:30
filter: filter.PlanCode是我需要根据planCode进行过滤的代码。另外,我必须将ng-model更改为filter.PlanCode。
https://stackoverflow.com/questions/26509716
复制相似问题