[英]AngularJs Filter on ng-repeat
Developing my app I encountered with a problem, I have a filter in my ng-repeat.开发我的应用程序时遇到问题,我的 ng-repeat 中有一个过滤器。 I can search by
productCode
or name.我可以按产品
productCode
或名称搜索。 After that appears a new requirement "Filter by SubcategoryId
".之后出现一个新的要求“Filter by
SubcategoryId
”。
The product is associated to a subcategory but I have the problem to filter exactly only by subCategoryId
strictly and the productCode
or name with proximity search.该产品与一个子类别相关联,但我有问题,只能严格按
subCategoryId
和接近搜索的productCode
或名称进行过滤。
Result:结果:
Filtering by subCategoryId = 1
按
subCategoryId = 1
过滤
Only I want to show subCategoryId
products but it brings a product list with SubcategoryId = 1, 11, 111 etc..只有我想显示
subCategoryId
产品,但它带来了 SubcategoryId = 1、11、111 等的产品列表。
It's there a way to filter exactly by subCategoryId
and the name, codigoProducto with proximity?有没有办法通过
subCategoryId
和名称 codigoProducto 精确过滤?
Filters Layout过滤器布局
<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>
List.列表。
<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}' >
Sorry for my bad English.抱歉我的英语不好。
Thank you so much if You can help me.如果你能帮助我,非常感谢。
Post Edited.帖子已编辑。
This is the jsfiddle.这是jsfiddle。
http://jsfiddle.net/schwertfische/2aW7Q/34/ http://jsfiddle.net/schwertfische/2aW7Q/34/
<ul><li ng-repeat="item in model.data | filter: { subCategoryId: filtros.subCategoryId }">{{item.title}}</li>
这是您的过滤器的示例
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.