vendredi 17 octobre 2014

How can I access the function applied in success of an $http.post?


Vote count:

0




I have this function triggered when I click a button.



.controller('Formctrl', function($scope, ichrisLayoutLeavebalanceService){
$scope.listRowSelected = function (list, item) {
var det = { detnumber: item.detnumber };
ichrisLayoutLeavebalanceService.callPost(det).success(function (data){ ichrisLayoutLeavebalanceService.leaveBalanceProcess(); });
};
});


However, it seems like I can't access the leaveBalanceProcess(). It seems like only the factory part is enabled to be shared. Here's my controller and factory code that is access by the code above.



.directive(/*code... code...*/{/*code... long code...*/
/*code... code...*/},
controller : ($scope, ichrisLayoutLeavebalanceService) {

function par(){
//code... code...
}
$scope.leaveBalanceProcess = function (){/*codes... codes... */}

$scope.build = function () {
ichrisLayoutLeavebalanceService.callPost(par()).success(function (data) { $scope.leaveBalanceProcess(data) });
}

$scope.build();
}
})
.factory('ichrisLayoutLeavebalanceService', ['$http', function ($http) {

var leaveBalanceService = {};

leaveBalanceService.callPost = function (par) {
return $http.post('/api/values/entries/LeaveBalanceEntries', par);
}

return leaveBalanceService;


}]);



asked 16 secs ago







How can I access the function applied in success of an $http.post?

Aucun commentaire:

Enregistrer un commentaire