简体   繁体   English

ng-repeat 上的 AngularJs 过滤器

[英]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 = 1subCategoryId = 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/

The model has changed so now it's working.模型已更改,因此现在可以使用了。 Thank You everybody for your help, Also I updated jsfiddle because it's a helpful source and You can rework.谢谢大家的帮助,我也更新了 jsfiddle,因为它是一个有用的来源,你可以返工。

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

JsFiddle提琴手

.... ....

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

这是您的过滤器的示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM