在 Parse.com 结果上使用 repeat

Using ng-repeat on Parse.com results

从 Parse.com 返回的原始结果在控制台中显示为 [child, child]

我想这意味着这个对象有三个级别?因此,为了在第一个 ng-repeat 中进行访问,我需要在推送到数组之前在控制器中执行一个 foreach,然后在 $scope 中使用它……似乎要获得我想要的东西还有很长的路要走。

是否可以在范围内使用来自 Parse.com 的原始结果。我想这样做:

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

然而,这给了我 child 元素 - 我是否必须 foreach,或者是否有一些 angular 诡计?

您可以在视图中执行 Parse.Object 的获取功能。

所以我把事情改成了

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

此功劳来自here

标记的答案不再有效 正确的方法是扩展对象,然后将值映射回 class 中您需要的任何项目。 然后,您可以正常绑定到 ng-repeat,而无需专门为 Parse 更改 html 代码。

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