Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

It seems I can't parse my JSON data from PARSE into my web app. When I try alert my JSON data, it shows like this

[{
    "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"
}]

But nothing appear in my view page, only createdAt and updatedAt with "" symbol.

My code

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>

Please advice. Thank you.

share|improve this question
    
So you just want the above data to display on the page via the properties object? –  tpie Apr 10 at 3:27
    
As long my data appeared. –  Dato' Mohammad Nurdin Apr 10 at 3:39
    
What is the structure of data before you stringify it? Something must be happening there. Can you log it or something and check the structure? –  tpie Apr 10 at 3:41
    
Thats all I got from Parse. –  Dato' Mohammad Nurdin Apr 10 at 3:51
    
success: function(data) { console.log(data); alert(JSON.stringify(data)); $scope.properties = data; it should log out an object. –  tpie Apr 10 at 3:52

1 Answer 1

I already found the answer.

$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));
    }
});
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.