Z
Z
zyulev2016-02-11 08:40:03
Angular
zyulev, 2016-02-11 08:40:03

How to make a GET request in Angular?

$http.get("lists.php")
.then(function(response) {
$scope.lists = response.data.lists;
console.log($scope.lists); // returns an array
});
console.log($scope.lists); // returns an empty array []

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rakro, 2016-02-11
@rakro

The request is being processed correctly. It's a matter of asynchrony. At the time of the second console.log get , the request had not yet completed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question