title: How to implement search in AngularJS
body: <p>I have frontend AngularJS application that connects to backend API.</p>
  
  <p>I'd like to implement search engine in my SPA so that I can specify</p>
  
  <ul>
  <li><code>offset</code> - the number of elements displayed on each page</li>
  <li><code>page</code> - number of current page</li>
  <li><code>count</code> - total elements</li>
  </ul>
  
  <p>I also want to sort the results by specified attribute and filter them out as well.</p>
  
  <p>What are the patterns to implement such search? What should be done on backend and what on frontend? How should API look like?</p>
  
  <p>I have a lot of issues with that - what if user requested for 5th page with offset 10, and then change offset to 20, which page should be displayed then? When to fetch additional data? What if I set offset to 15 and then filter out some results, what will give me only 5 elements? Should I fetch missing by current filter?</p>
  
  <p>Can you provide some behaviors of that mechanisms?</p>