I am trying to use Angular JS service for various purpose. I already made functions inside main script.js but want to shift in employeeService.js service file. Inside it, I am trying to implement a Delete functionality,Here is code-
/// <reference path="script.js" />
app.factory('fetchEmpService', function () {
var deleteEmp = function (EID) {
if (confirm("Are you sure want to delete?")) {
$http({
method: "POST",
url: 'EmpWebService.asmx/DeleteEmployee',
data: { EmpId: EID },
headers: { 'Content-Type': 'application/json; charset=utf-8' }
})
.then(function (reponse) {
alert("Deleted successfully.");
$scope.getEmployee();
});
}
}
return {
deleteEmp:deleteEmp,
};
});
And in my main script.js file-
$http.get("EmpWebService.asmx/GetEmp")
.then(function (response) {
$scope.employees = response.data;
});
The sevice is running and control goes inside it but its throwing following error- angular.js:5582 ReferenceError: $http is not defined.
Similarly I was trying to call a method of fetching EmployeeList function its giving error. What may be the reason? Is there any issue regarding web service that I am using?