AngularJS - Select2 Infinite Scroll with Remote Data

I really like the select2 project, I've already used the library with the different configurations. I could not find however a good sample code for using it's infinite scroll option with AngularJS, so I made my own. Here's is my AngularJS version to the select2 docs Infinite Scroll with Remote Data code sample


Using a Provider

The select2 collects it's data from an external API. API calls are made from a service, Obviously, calling this service from the Directive it self is a bad idea, that's why I used a provider for this purpose. The provider is accessed by the directive and returns a Promise while performing the service call. This way I keep my code components loosely coupled.


 $scope.movieListProvider = {  
    readData: function(term, page, pageSize) {  
     var deferred = $q.defer();  
      q: term,  
      page_limit: pageSize,  
      page: page + 1  
      .$promise.then(function(data) {  
      }, function(reason) {  
     return deferred.promise;  

See the full source code here

Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at