Answer the question
In order to leave comments, you need to log in
How to process json in angularJS?
I make a request in angularJS to the API:
$http.get('').
success(function(data, status, headers, config) {
$scope.dialogs = data;
}).
error(function(data, status, headers, config) {
// log error
});
{
"status": "success",
"response": [
{
"id": "32",
"id_user": "31",
"id_contact": "32",
"name": "admin2",
"login": "admin2",
"email": "[email protected]",
"hash": "$2y$11$2a7b86bb9cf7d08b92fa0uVmJM1lw\/EVo.1w3Oqlg8.Sb9gDbKsYW",
"key": "$2y$11$9938ba8be955f8cb1f3b4u0\/CL5AeVY88bqd7Dla03hkdUGHP6GYu",
"date_reg": "2014-12-16",
"approved": "1"
}
]
}
Answer the question
In order to leave comments, you need to log in
Apparently you have a number of users in response.
This code will display some fields on the page.
<div ng-repeat="user in dialogs.response">
<p>{{ name }}</p>
<p>{{ login }}</p>
<p>{{ data_reg }}</p>
</div>
angular.fromJson(data) or what is the problem?
JSON is just a string, what and why are you going to access it? At least it must first be deserialized into an object and the view must already be attached to it.
well, in the dialogs, you probably still need to throw not data, but data.response .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question