alex
alex

Reputation: 7601

Why is this fetched data not being shown in my HTML?

I'm fetching some objects form a Parse database and displaying them in my template:

JS:

angular.module('yoApp')
  .controller('downloadsCtrl', function($q, $scope, $rootScope, $http, appService, serviceUpload, fileUpload) {
    $scope.downloads = []
    var Download = Parse.Object.extend('Download')
    var query = new Parse.Query(Download)
    query.find({
      success: function(results) {
        _.each(results, function(result) {
          $scope.downloads.push(result.toJSON())
          console.log($scope.downloads)
          $scope.$apply
        })
      },
      error: function(error) {
        // The object was not retrieved successfully.
        // error is a Parse.Error with an error code and message.
      }
    })
  })

HTML:

<pre>{{downloads | json}}</pre>

console.log($scope.downloads) outputs the objects: [Object, Object].

But they are not being displaying between the <pre></pre>

Why is this? And how to accomplish what I want?

Upvotes: 0

Views: 48

Answers (1)

Voreny
Voreny

Reputation: 785

You forgot to execute the $apply function. Try changing that to $scope.$apply();

Upvotes: 1

Related Questions