title: Processing large amounts of data in AngularJS coming from Codeigniter Restful API?
body: <p>I'm currently novice in both PHP and AngularJS (although my main focus is AngularJS), anyways I picked up an open source music project(uses Codeigniter) I found online, just for learning purposes. The project basically is setup to have a user sign up , upload music and then have it display on their profile, as well as a section where you can browse through everyone's music.</p>
  
  <p>So I've built/been-building an angularJS app from this project using the API library that came with the project. I pretty much got everything working, loading users information, displaying/playing the music in all the correct views, etc.</p>
  
  <p>There's just one problem with the AngularJS based APP, I've been striving to find a solution for. The API that retrieves everyones music for the "discover" section, sends ALL of it from the database. At first I didnt notice the problem because I only had two ficticious users signed up, with a total of 20 songs, so the discovery section did not take to long to load. But upon futher testing, I decided to replicate more users, for a total 500 users and a total of 1000 songs. This is where I noticed a huge difference in load time.</p>
  
  <p>So basically my question is what would be the recommended approach to handle this? Is there a way in AngularJS to limit the amount of data it reads in at a time? (for example, only load 20 songs initially then load 20 more after clicking "View more") or is this something that should be handled by PHP?</p>
  
  <p>Here is the simple API function that was predefined in this project.</p>
  
  <pre><code>    function discovery_get(){
      $result = $this-&gt;db-&gt;query("select * from user_songs ORDER BY song_views DESC")-&gt;result();
      $this-&gt;response($result, 200);
  }
  </code></pre>
  
  <p>Example snippet how api is called:</p>
  
  <pre><code>$http.jsonp('http://myapi.dev/api/discovery/?callback=JSON_CALLBACK').then(function (data) {
      $scope.discovery = data.data;
      //console.log(data);
     // some more code here....
  });
  </code></pre>
  
  <p>Thank you for any responses, and I apologize in advance if my question is all over the place. Have a great day!</p>