title: Angularjs not update $scope
body: <p>I'm having trouble with my controller not updating Gui <code>$scope</code>.
  After some research, I found out that you can use <code>$timeout</code>.</p>
  
  <p>The service takes different time on different units and I do not want set like 5000 timeout because the app feels slow.
  Is there any other way to do this?</p>
  
  <pre><code>.service('RowService', function ($q) {
  
  var rows = undefined;
  this.getrows = function (id) {
    var local = new PouchDB('db');
    var deferred = $q.defer();
    //      var rows = [];
    local.query(function (doc, emit) {
      emit(doc.type);
    }, { key: 'row_detail' }).then(function (result) {
      var rows = [];
      for (i = 0; i &lt; result.rows.length; i++) {
        local.get(result.rows[i].id).then(function (response) {
          if (response.orderid == orderId) {
            rows.push(response);
          }
          deferred.resolve(rows);
        })
      }
    }).catch(function (err) {
      // handle any errors
    });
  
    rows = deferred.promise;
  
    return $q.when(rows);
  }
  
  })
  
  
  RowService.getrows($stateParams.id).then(function (data) {
  
      // Not working example
      $scope.rows = data;
      // Working example
  
    $timeout(function () {
      $scope.rows = data;
    }, 5000)
  
  }
  </code></pre>