Usually, when I get some async way of data, I would do it like
var promise = $http.get('/api/v1/movies/avengers');
promise.then(
function(payload) {
$scope.movieContent = payload;
});
In fact, the script is very common - I send some kind of request, and when it is ready, I am sure that it returns to some variable / prop. But every time a callback is required, even if the callback is always the same.
Is there any way to do this like
$scope.movieContent = $http.get('/api/v1/movies/avengers'); //updates to real value when request is done
or kind
updateWhenReady($scope.movieContent , '/api/v1/movies/avengers');
It doesnโt matter, but when used, a lot makes a difference in my opinion.
source
share