Daniel Daniel - 9 months ago 46
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?


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

$scope.caller = function (somefunc) {