I have this REST service, which speaks with LDAP server. In order to get all available data about user, I must visit this:
GET /users/:userId
Because user in LDAP is described by attributes, I want to get only some not all attributes. In this case must do this:
GET /users/:userId/o/mail/displayName/....(list of attributes required)
How to create this dynamic url for attribute list while using AngularJS $resource?
.factory('User', ['$resource', 'REST_API_URL', function ($resource, REST_API_URL) {
var User = $resource(
REST_API_URL + '/users/:id',
{id: '@id'}
);
return User;
}])
The first URL you describe follows RESTful convention, but not the second one. When there are actions verbs (here displayName) in URIs, your API is no longer RESTful.
AngularJS $resource interacts with RESTful server-side data sources only. Your API must follow a lot of RESTful conventions.
I recommend you read answers to this question which is highly related and describe those conventions.
As your API does not meet these criteria you will have to build your own $resource-like CRUD service based on the lower-level $http service . ( example here )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.