0

I seem to be missing something here with filtering an ng-repeat with a search box.

<li ng-if="searchTab"><input type="text" class="form-control" placeholder="Search"  ng-model="search" >
  </li>

and the ng-repeat

<div dir-paginate="saving in savings| orderBy:orderByField:!reverseSort| filter:search | filter:{retailer:filterBy}|itemsPerPage:10" class="list-group-item">

is there any obvious reason why the filter doesnt do anything when i type in the search box?

Edit - I notice that if i remove the ng-if it works. Is there any way of using both?

1
  • Can you provide a JS fiddle Commented Mar 19, 2016 at 4:27

2 Answers 2

1

If the value for searchTab is false during the initialisation phase of the controller then the input div is not evaluated. Hence the ng-model directive wont create the variable 'search' on the controller scope. So please declare 'search' as a variable in your controller.

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

1 Comment

It was actually declared but this morning i had the idea of changing the ng-if to ng-show and it worked straight away.
0

Instead of using ng-if use ng-show.

<li ng-show="searchTab"><input type="text" class="form-control" placeholder="Search"  ng-model="search" >
  </li>

1 Comment

Please add some explanation. Your answer is currently flagged "low quality" and might eventually be removed without.

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.