title: [AngularJS][Ionic] Make Controller wait for Service that uses another $http service
body: <p>The problem is that Controller doesn't wait for Service that uses another $http service, and I get no data.</p>
  
  <p>services.js:</p>
  
  <pre><code>angular.module('starter.services', [])
      .factory('Likes', function ($http) {
          var likes;
          $http.get("http://localhost:8100/js/offers.json")
                  .success(function (results) {
                      likes = results.offers;
                      console.log("ok!");
                  })
                  .error(function (results) {
                      console.log("error");
                  });
          return {
              all: function () {
                  return likes;
              },
              get: function (likeId) {
                  for (var i = 0; i &lt; likes.length; i++) {
                      if (likes[i].id === parseInt(likeId)) {
                          return likes[i];
                      }
                  }
                  return null;
              }
          };
  
      })
  </code></pre>
  
  <p>controllers.js (part):</p>
  
  <pre><code>.controller('OneCtrl', function($scope, $stateParams, Likes) {
    $scope.offer = Likes.get($stateParams.likedId);
  })
  
  .controller('LikedCtrl', function($scope, $stateParams, $http, Likes) {
    $scope.liked = Likes.all();
  })
  </code></pre>
  
  <p>I've read articles and topics about promises, async(), callbacks, and $q but I have no idea how to integrate those things in my code, despite numerous attempts.</p>