AngularJS allows to define async functions. An example is the $http service. HTTP service calls an API and returns a response as a promise.

$http.get(url)
    .then(function(res){
        // handle the response
    }, function(res){
        // handle the error
    });

Retrieve the result from the Promise object using then function. The function has two arguments: onSuccess callback and onFailure callback.

The $q service in AngularJS creates a promise using the defer function.…

Read More