0

I am trying to filter with few properties of a json output in Angular.js, here is my plunker link.

The actual problem is, if i am trying to filter by type 1, than it automatically color filter value is also get checked, i want both filters should be applied separately or combined.

I want this filter to be applied on a e-commerce site for selecting the brands, category, minimum and maximum price etc.

How should this filter function should be written in angular.

1 Answer 1

1

The problem is that you are using the same checked property and ng-model in both different types of checkboxs

ng-checked="person.checked" ng-model="person.checked"

Instead you should use two different models for example person.checked.type and person.checked.color, should be something like:

//in type checks
<input type="checkbox" ng-checked="person.checked.type" ng-model="person.checked.type"/> {{ person.type }} 

//in color checks
<input type="checkbox" ng-checked="person.checked.color" ng-model="person.checked.color" {{ person.color }}

Update

Here is a working plunker

Sign up to request clarification or add additional context in comments.

5 Comments

after updating, even filter thing is also not working,
I added to the answer an updated plunker it's working fine, off course you also need to update your filters logic
I updated your plunker it's working fine, off course you also need to update your filters logic
What was the issue, so that i can understand it better, do some thing more advanced with filter?
Nope, each filter should have it's own "filtered" condition

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.