Recently, I've been working on some AngularJS code involving a service and controller.
angular.module('myModule', []).service("AttendanceService", function ($http) {
this.getdata = function () {
return $http({
method: "post",
url: "Dashboard/GetAttendanceReport",
params: [{ EmpID: $("#nameofEmp").val(), YearID: $("#YearIn").val() }],
dataType: "json"
});
};
}).controller('myController', function ($scope, AttendanceService) {
GetAlldata();
function GetAlldata()
{
var getAttendanceData = AttendanceService.getdata();
}
})
In my current setup, all I need is to call the above service like so:
return $http({
method: "post",
url: "Dashboard/GetAttendanceReport",
params: [{ EmpID: $("#nameofEmp").val(), YearID: $("#YearIn").val() }],
dataType: "json"
});
with just a button click
$("#btnLoad").click(function (event) {
});
I'm wondering if this can be done. This is all pretty new to me...