Wednesday, 15 June 2011

angularjs - How can I code some function that executes if my $http has a success or error? -



angularjs - How can I code some function that executes if my $http has a success or error? -

i have simple $http call:

$http({ url: '/api/abc/post', method: "post", data: home.modal.data }) .success(function (result) { }) .error(function(error) { });

how can code function execute @ end after either .success or .error has returned ?

$http returns promise. on recent angular versions, finally method of promise want, grab that, since reserved word javascript, have phone call as:

$http({...}) .success(function (result) {...}) .error(function(error) {...}) ['finally'](function() {...});

angularjs

No comments:

Post a Comment