解析 - 无法使用angular解析/检索JSON

时间:2015-04-10 02:38:00

标签: javascript json angularjs parse-platform

似乎我无法将我的JSON数据从PARSE解析到我的网络应用程序中。当我尝试提醒我的JSON数据时,它会显示如下

[{
    "address1": "Test",
    "address2": "Test",
    "bathroom": "1",
    "bedroom": "1",
    "builtUpArea": "123",
    "cityId": "1",
    "countryId": "1",
    "description": "Test",
    "exclusive": true,
    "facingDirectionId": "1",
    "floorlevel": "1",
    "furnishTypeId": "1",
    "landArea": "123",
    "landAreaTypeId": "1",
    "name": "Test",
    "ownerContact": "Test",
    "ownerEmail": "Test",
    "ownerIc": "Test",
    "ownerName": "Test",
    "poscode": "123",
    "price": "Test",
    "purchaserId": "xZyLAKnCnXt",
    "remark": "Test",
    "stateId": "1",
    "statusId": "1",
    "tenureId": "1",
    "typeId": "1",
    "user": {
        "__type": "Pointer",
        "className": "_User",
        "objectId": "rquoctPnNz"
    },
    "objectId": "0nfSPUwgvm",
    "createdAt": "2015-04-10T02:16:54.509Z",
    "updatedAt": "2015-04-10T02:16:54.509Z"
}]

但我的视图页面中没有显示任何内容,只有createdAtupdatedAt带有""符号。

我的代码

的javascript

var Property = Parse.Object.extend("Property");
        var user = Parse.User.current();
        var query = new Parse.Query(Property);
        query.equalTo("user", user);
        query.find({
            success: function(data) {
                alert(JSON.stringify(data));
                $scope.properties = data;
            },
            error: function(object, error) {
                alert(JSON.stringify(error));
            }
        });

HTML

<tr ng-repeat="property in properties | filter:query">
                                        <td>{{property.name}}</td>
                                        <td>RM {{property.price}}</td>
                                        <td>{{property.createdAt}}</td>
                                        <td>{{property.updatedAt}}</td>
                                    </tr>

请指教。谢谢。

1 个答案:

答案 0 :(得分:0)

我已经找到了答案。

$scope.properties = [];
var Property = Parse.Object.extend("Property");
var user = Parse.User.current();
var query = new Parse.Query(Property);
query.equalTo("user", user);
query.find({
    success: function(data) {
        var index = 0;
        var Arrlen = results.length;
        for (index = 0; index < Arrlen; ++index) {
            var obj = results[index];
            $scope.properties.push({
                objectId: obj.attributes.objectId,
                name: obj.attributes.name,
                price: obj.attributes.price,
                createdAt: obj.createdAt,
                updatedAt: obj.updatedAt
            });
        }
    },
    error: function(object, error) {
        alert(JSON.stringify(error));
    }
});