I guess the title is pretty much clear what I am asking. I have created this fiddle : http://jsfiddle.net/Sourabh_/HB7LU/13142/
In the fiddle I have tried to replica
If you want to immidate an API-Rest-Call, use the returned promise
in your Controller
instead setting the scope inside the Rest-Call.
$http.get('uri')
.success(function(data) {
$scope.items = data
});
Avoid using $apply()
. From the Angular GitHub Repo:
$scope.$apply()
should occur as close to the async event binding as possible.Do NOT randomly sprinkle it throughout your code. If you are doing if
(!$scope.$$phase) $scope.$apply()
it's because you are not high enough in the call stack.
To your question:
$apply()