У меня есть два API, которые делают ту же работу.1) По умолчанию я получаю текущие данные о сотрудниках.2) Я передаю параметры, чтобы получить данные выбранной даты.Как я могу уменьшить свой код до одного API?
app.controller("attCtrl", ['$scope', '$filter', '$http', function ($scope, $filter, $http) {
jQuery("body").on("focus", ".time-input", function () {
if (!jQuery(this).data('xdsoft_datetimepicker')) {
jQuery(this).datetimepicker({
onGenerate: function () {
if (!jQuery(this).hasClass('initial')) {
jQuery(this).addClass('initial').triggerHandler('open.xdsoft');
}
}
});
}
});
$scope.empattendance = [],
//I want to send default date while calling this api
$http.get('xyz/api/att/view/date')
.then(function (result) {
console.log(result);
$scope.empattendance = result.data.result;
$scope.empDetails = result.data.result1;
}, function (data, status) {
console.log(data);
});
$scope.getEmpAttendance = function () {
var employeeAttendance = {
startdate: jQuery('#start').val(),
enddate: jQuery('#end').val(),
employee: $scope.selectedItem
}
employeeAttendance.startdate = employeeAttendance.startdate.slice(0, -6);
employeeAttendance.enddate = employeeAttendance.enddate.slice(0, -6);
console.log(employeeAttendance);
$http.get('xyz/api/att/view/today', employeeAttendance)
.then(function (result) {
console.log(result);
$scope.empattendance = result.data.result;
});
}
}]);