AdrianM
AdrianM

Reputation: 33

AngularJs and Parse

I wanted to try to build something with AngularJs and Parse as the back end. I found some tutorials now I have this in one of my controllers:

 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);
    }

in my view I have a ng-repeat and everything works fine, but when I try to get the objectId or the ceatedAt I can't.

I add:

      $scope.sessions = results.map(function(obj) {
        return {points: obj.get("points"), gameDate: obj.get("gameDate"),  gameId: obj.get("objectId"), createdAt: obj.get("createAt"), parseObject: obj};

But in my view they are not displayed, although when I check the XHR responses this fields are present.

Upvotes: 2

Views: 513

Answers (1)

Daniel Bank
Daniel Bank

Reputation: 3899

You should be able to access the objectId and createdAt as properties of obj, as follows:

var objectId = obj.id;
var updatedAt = obj.updatedAt;
var createdAt = obj.createdAt;

See the Retrieving Objects section of the Parse JavaScript Guide.

Upvotes: 1

Related Questions