1
У меня есть AngularJS сервис и контролер код.Как позвонить услуге angularJs при нажатии кнопки?
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();
}
})
То, что я хочу, это просто позвонить выше службы т.е.
return $http({
method: "post",
url: "Dashboard/GetAttendanceReport",
params: [{ EmpID: $("#nameofEmp").val(), YearID: $("#YearIn").val() }],
dataType: "json"
});
кнопку мыши
$("#btnLoad").click(function (event) {
});
ли это возможно? Я новичок в этом ...
Я получаю неперехваченный ReferenceError: ошибка AttendanceService не определена – akash
вам нужно вводить свой сервис «» AttendanceService с кавычками. как «AttendanceService» или «AttendanceService» в ваш контроллер ......... –
Я уже сделал, что – akash