I am facing an issue with my two angularjs services. One is supposed to retrieve a single user while the other should return an array of users. However, both seem to be calling the service that returns an array of users. Can you help me understand why this is happening?
Below are the definitions of the two angularjs services:
angular.module('clearsoftDemoApp').factory('UserDetail', function ($resource) {
return $resource('http://localhost:8080/ClearsoftDemoBackend/webresources/clearsoft.demo.users/:id', {}, {
find: {method: 'GET', params: {id: '@id'}},
update: { method: 'PUT', params: {id: '@id'} },
delete: { method: 'DELETE', params: {id: '@id'} }
});
});
angular.module('clearsoftDemoApp').factory('Users', function ($resource) {
return $resource('http://localhost:8080/ClearsoftDemoBackend/webresources/clearsoft.demo.users', {}, {
findAll: {method: 'GET', isArray: true}
});
});
Additionally, here is a snippet of the Java RESTful service code:
@Stateless
@Path("clearsoft.demo.users")
public class UsersFacadeREST extends AbstractFacade<Users> {
@PersistenceContext(unitName = "ClearsoftDemoBackendPU")
private EntityManager em;
public UsersFacadeREST() {
super(Users.class);
}
@GET
@Path("{id}")
@Produces({"application/xml", "application/json"})
public Users find(@PathParam("id") Integer id) {
return super.find(id);
}
@GET
@Override
@Produces({"application/xml", "application/json"})
public List<Users> findAll() {
return super.findAll();
}
The issue I am facing is that both angularjs services are unintentionally calling the findAll() web service instead of the intended ones. Any insights on resolving this would be greatly appreciated.