title: Paging angularjs $scope variable is undefined
body: <p>I'm having trouble recovering service data to insert into the scope of variable.
  My ctrl:</p>
  
  <pre><code>'use strict';
  var app = angular.module('ezcms2App.controllers', []);
  
  app.controller('NoticiaCtrl', ['$scope', 'NoticiasFactory', '$http',
  function ($scope, NoticiasFactory, $http) {            
  </code></pre>
  
  <p>//Test paging local array - It's work
      $scope.makeTodos = function () {
          $scope.todos = [];
          for (var i = 1; i &lt;= 20; i++) {
              $scope.todos.push({text: 'todo ' + i, done: false});
          }
       //It's not working, $scope.todos = undefined
      /<em>$scope.todos= NoticiasFactory.query(function (entries) {
       for (var i in entries) {
              $scope.todos.push(entries[i);
          }
       });</em>/
      };</p>
  
  <pre><code>$scope.makeTodos();
  
  $scope.totalItems = $scope.todos.length;
  
  $scope.filteredTodos = []
          , $scope.currentPage = 1
          , $scope.numPerPage = 10
          , $scope.maxSize = 5;
  
  
  
  $scope.numPages = function () {
      return Math.ceil($scope.todos.length / $scope.numPerPage);
  };
  
  $scope.$watch('currentPage + numPerPage', function () {
      var begin = (($scope.currentPage - 1) * $scope.numPerPage)
              , end = begin + $scope.numPerPage;
  
      $scope.filteredTodos = $scope.todos.slice(begin, end);
  });
  </code></pre>
  
  <p>}]);</p>
  
  <p>I also tried via http get and how not asynchronous he gives also undefined   </p>
  
  <pre><code> 'use strict';
      var app = angular.module('ezcms2App.controllers', []);
  
      app.controller('NoticiaCtrl', ['$scope', 'NoticiasFactory', '$http',
       function ($scope, NoticiasFactory, $http) {            
  
         $scope.makeTodos = function () {
          $http.get('http://localhost:9292/localhost:80/apiadmin/index.php/api/noticia').success(function (resp) {
              $scope.todos = resp.data;
          });
  
      };
  
          $scope.makeTodos();
  
          $scope.totalItems = $scope.todos.length;
  
          $scope.filteredTodos = []
                  , $scope.currentPage = 1
                  , $scope.numPerPage = 10
                  , $scope.maxSize = 5;
  
  
  
          $scope.numPages = function () {
              return Math.ceil($scope.todos.length / $scope.numPerPage);
          };
  
          $scope.$watch('currentPage + numPerPage', function () {
              var begin = (($scope.currentPage - 1) * $scope.numPerPage)
                      , end = begin + $scope.numPerPage;
  
              $scope.filteredTodos = $scope.todos.slice(begin, end);
          });
  
  
      }]);
  </code></pre>