AngularJs过滤ng-repeat

时间:2013-12-13 19:43:37

标签: javascript html angularjs

开发我的app我遇到了问题,我的ng-repeat中有一个过滤器。 我可以通过productCode或名称进行搜索。 之后出现一个新的要求“按子类别过滤”。

产品与一个子类别相关联,但我的问题是只能通过subCategoryId严格过滤,而productCode或名称过滤搜索。

结果: 按subCategoryId = 1过滤 只有我想显示subCategoryId产品,但它带来了SubcategoryId = 1,11,111等产品列表。

有一种方法可以通过subCategoryId和名称,codigoProducto精确过滤。?

过滤布局

 <input placeholder="PALABRA CLAVE" type="text" ng-model="filtros.name"  ng-change="changeCurrentPage(0);" />
 <input placeholder="CODIGO PRODUCTO" type="text" ng-model="filtros.codigoProducto"  ng-change="changeCurrentPage(0);"/>
 <select ng-model="filtros.subCategoryId" ng-change="changeCurrentPage(0)">
     <option  value="">TODOS</option>
     <option ng-repeat="subct in subCategories" value="{[{subct.id}]}"{[{subct.name}]}</option>
</select>

列表。

<li ng-animate="'animate'" ng-repeat="prod in objtemp.products | orderBy:'ordenProducto' | filter:filtros | startFrom:currentPage*pageSize:this | limitTo:pageSize" ng-class='{marginLeftNone: $index%4==0}' >

抱歉我的英语不好。

非常感谢你能帮助我。

发布后编辑。

这是jsfiddle。

http://jsfiddle.net/schwertfische/2aW7Q/34/

2 个答案:

答案 0 :(得分:1)

模型已经改变,现在它正在运作。谢谢大家的帮助,我也更新了jsfiddle,因为它是一个有用的来源,你可以返工。

..... var myApp = angular.module('myApp',[]); .....

JsFiddle

...

答案 1 :(得分:0)

<ul><li ng-repeat="item in model.data | filter: { subCategoryId: filtros.subCategoryId }">{{item.title}}</li>

这是您的过滤器的示例

相关问题