Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJs Filter on ng-repeat

Developing my app I encountered with a problem, I have a filter in my ng-repeat. I can search by productCode or name. After that appears a new requirement "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.

Result:

Filtering by subCategoryId = 1

Only I want to show subCategoryId products but it brings a product list with SubcategoryId = 1, 11, 111 etc..

It's there a way to filter exactly by subCategoryId and the name, codigoProducto with proximity?

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.

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

like image 659
schwertfisch Avatar asked Aug 16 '26 04:08

schwertfisch


1 Answers

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.

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

JsFiddle

....

like image 150
schwertfisch Avatar answered Aug 17 '26 19:08

schwertfisch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!