How to implement pull to refresh


I’m trying to implement on pull to refresh on the sample tabs app. The only thing I changed is to pull data from remote JSON. See the services.js here:

angular.module('', [])

 * A simple example service that returns some data.
.factory('Friends', function($http) {
  var friends = [];

    .success(function(data, status, headers,config){
      console.log('data success');
      console.log(data); // object seems fine
    .error(function(data, status, headers,config){
      console.log('data error');
      friends =;

  return {
    all: function() {
      return friends;
    get: function(friendId) {
      // Simple index lookup
      return friends[friendId];

I have read the and now I just don’t get where exactly and how I should put all.



Best bet is to check the codepens, they have a pretty detailed example of pull-to-refresh.


@mhartington yes but unlike that example we have templates, controllers and services. For a beginner like myself it’s kinda confusing to understand where to take those examples and glue all together in a working sample app.


Here is a more “advanced” demo that has a factory for returning airline data. So, you can see infinite scroll. It does NOT do PTR, but you can get the gist of it.

However, the reality is that all CodePen’s are limited in their nature. You can’t see a good directory structure, etc. You need to take the best practices from experience and others in the AngularJS community to figure out what works best for you.

Here is a link to a shallow article I wrote on it for my use :

Here’s a very in-depth best practices guide :