**This is my service.js file. this code not working what is the wrong. And how to create service file. This links will execute category list with product. The scenario is when click on the category I need to show products. **
angular.module('directory.services', [])
.factory('EmployeeService', function($q) {
return $http.get('http://localhost/youtubewebservice/shop-categorylist-product.php')
return {
findAll: function() {
var deferred = $q.defer();
deferred.resolve(employees);
return deferred.promise;
},
findById: function(employeeId) {
var deferred = $q.defer();
var employee = employees[employeeId - 1];
deferred.resolve(employee);
return deferred.promise;
},
findByName: function(searchKey) {
var deferred = $q.defer();
var results = employees.filter(function(element) {
var fullName = element.firstName + " " + element.lastName;
return fullName.toLowerCase().indexOf(searchKey.toLowerCase()) > -1;
});
deferred.resolve(results);
return deferred.promise;
},
findByManager: function (managerId) {
var deferred = $q.defer(),
results = employees.filter(function (element) {
return parseInt(managerId) === element.managerId;
});
deferred.resolve(results);
return deferred.promise;
}
}
});