How to create a custom entity in ng-admin

111 Views Asked by At

I have an admin dashboard powered by ng-admin.From the documentation, I understand that each entity corresponds to an endpoint in the baseApiUrl. Here is my question :

Working example :
baseApiUrl : http://my-host.com/v0
entity : var user = nga.entity('users') (translates to => http://my-host.com/v0/users)

What I tried:
baseApiUrl : http://my-host.com/v0
entity : var userProfiles = nga.entity('users').url('/profiles');

All I want is an entity to be created which corresponds to http://my-host.com/v0/users/profiles

Here userProfiles can be passed as an argument to targetEntity and used as a reference type field.

However, userProfiles is not recognised as an entity and I cannot define a listView consisting of only userProfiles. Does this mean that entity cannot be created when the url has any levels as shown above.

1

There are 1 best solutions below

0
On

I just realised how this can be done :

var userProfiles = nga.entity('profiles').baseApiUrl('http://my-host.com/v0/users/');

Note that the baseApiUrl is overridden for this entity.