3

When using ng-repeat I want to filter object by two values (name and description). I want to filter this array in way if in any key exists value in search it will return it. When I'm trying this filter:{info:{name:search, description:search}} the result is when value from search equals in both.

5
  • Kindly make the question more understandable. Do you have a search box and bases upon input there you want to filter the ng-repeat values? Commented May 17, 2016 at 11:18
  • Yes, I have input for search and i want use only one. Commented May 17, 2016 at 11:21
  • You have a search box and based on it you want to control the values in ng-repeat, right? 'I have input on search part' - I don't get it. Commented May 17, 2016 at 11:23
  • Yes, I have a search box and based on it I want to control the values. Commented May 17, 2016 at 11:28
  • is this is what you wanted mate? Commented May 17, 2016 at 12:01

1 Answer 1

1

Okay so based on what I have been able to understand. Although I am not sure if this is what you wanted, if not let me know and I will delete this answer.

Let's say you have object that has values in this format which you are feeding to ng-repeat.

  $scope.inputobject = [
    {name: 'xyz', description: 'hadhash'},
    {name: 'uza', description: 'hadhahdh'},
    {name: 'aaa', description: 'hadhahas'}  
  ];

This is our HTML part now, add the controller and all, I hope that wont be a problem.

<input type="text" placeholder="search" ng-model="objectsearch">
<div ng-repeat="x in inputobject | filter:{name:objectsearch}">
<div>
{{x.name}} {{x.lastname}}
</div>
</div>

Now filter will only happen based on first input. Cheers!

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

Comments

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.