单击按钮时触发了此功能。
.controller('Formctrl', function($scope, ichrisLayoutLeavebalanceService){
$scope.listRowSelected = function (list, item) {
var det = { detnumber: item.detnumber };
ichrisLayoutLeavebalanceService.callPost(det).success(function (data){ ichrisLayoutLeavebalanceService.leaveBalanceProcess(); });
};
});
然而,似乎我无法访问leaveBalanceProcess()。看起来只有工厂部件可以共享。这是我的控制器和工厂代码,可以通过上面的代码访问。
.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;
}]);
那么我现在如何访问整个控制器?