可以't使用Angular解析/检索JSON

Can't parse/retrieve JSON using Angular

本文关键字:解析 检索 JSON Angular 使用 可以      更新时间:2023-09-26

我似乎无法将parse中的JSON数据解析到我的web应用程序中。当我尝试提醒我的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>

我已经找到了答案。

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