Taylorsuk
Taylorsuk

Reputation: 1449

Using ng-repeat on Parse.com results

The raw results returned from Parse.com are shown in the console as [child, child].

I imagine this means that there are three levels to this object? So in order to access in the first ng-repeat do I need to do a foreach in the controller before pushing to an array and then use that in $scope... seems a long way around to get what i want.

Is it possible to use the raw results from Parse.com in the scope. I would like to do this:

var query = new Parse.Query("Programme");
query.equalTo("userId", userId);
query.find()
.then(function(result){
        $scope.programmes = result;
        console.log($scope.programmes);
});

However this gives me the child elements - do I have to foreach, or is there some angular trickery?

Upvotes: 2

Views: 678

Answers (2)

Abs
Abs

Reputation: 455

The marked answer is not working any more The proper way is to extend the object and then map the values back to whatever items you need in that class. Then you can bind in normally to ng-repeat without changing your html code specifically for Parse.

var Game = Parse.Object.extend("Game"); 
var query = new Parse.Query(Game);
query.find({
success: function(results) {
  $scope.$apply(function() {
  $scope.games = results.map(function(obj) {
    return {points: obj.get("points"), gameDate: obj.get("gameDate"),  parseObject: obj};
  });
});
},

error: function(error) {
  console.log(error);
}

Upvotes: 1

Taylorsuk
Taylorsuk

Reputation: 1449

You are able to perform Parse.Object's get function within the view.

So I changed things to be

{{programme.get('title')}}

Credit for this is from here

Upvotes: 2

Related Questions