[英]Can't parse/retrieve JSON using Angular
It seems I can't parse my JSON data from Parse into my web app. 看来我无法将Parse中的JSON数据解析到Web应用程序中。 When I try alert my JSON data, it shows like this 当我尝试提醒我的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"
}]
But nothing appear in my view page, only createdAt
and updatedAt
with ""
symbol. 但没有出现在我的视图页面,只有createdAt
和updatedAt
用""
符号。
My code: 我的代码:
JavaScript: 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: 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>
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));
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.