Search only when you click the button

Asked

Viewed 30 times

0

I’m trying to make an advanced search system with Angularjs, but I have a problem when finishing the search. The code is this:

 <div ng-init="friends = [{name:'John', phone:'555-1276'},
                     {name:'Mary', phone:'800-BIG-MARY'},
                     {name:'Mike', phone:'555-4321'},
                     {name:'Adam', phone:'555-5678'},
                     {name:'Julie', phone:'555-8765'},
                     {name:'Juliette', phone:'555-5678'}]"></div>
 <hr>
 <label>Name only <input ng-model="search.name"></label><br>
 <label>Phone only <input ng-model="search.phone"></label><br>
 <button>Pesquisar</button>

 <table id="searchObjResults">
   <tr><th>Name</th><th>Phone</th></tr>
   <tr ng-repeat="friendObj in friends | filter:search:strict">
   <td>{{friendObj.name}}</td>
   <td>{{friendObj.phone}}</td>
   </tr>
 </table>

In the plunker: plnkr.co

However, in this code as you search the result will appear and I want it to appear only when the user clicks the search button, as I do it?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.