Daniel Daniel - 1 year ago 95
Javascript Question

Angular pass callback to promise

How can I pass the callback to be handled by a promise as a parameter to the calling function? For example, I have

$scope.caller = function() {
$http({...}).then(successCallback(response) {
}, function errorCallback(response) {

How can I pass an anonymous function to
to be evaluated when the promise completes?

Answer Source

You can pass your function as a parameter to $scope.caller.

$scope.caller = function (somefunc) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download