-
Notifications
You must be signed in to change notification settings - Fork 1
ModelConfig
Mihael Safaric edited this page May 29, 2019
·
5 revisions
A decorator used for configuring a model. It takes one argument, ModelOptions. The argument interface and the default values can be checked here.
-
type:string- unique name of the model class
-
endpoint- sets the model endpoint which is used for building request URLs
- either this property has to be set or the
endpointgetter on a model has to be implemented
-
halDocumentClass:HalDocumentConstructor<HalModel>- optional
- if set, this class will be used instead of
HalDocumentclass
-
network:NetworkConfig- optional
- overrides the network config specified on a datastore level
DatastoreConfig
import { HalModel, ModelConfig } from 'ngx-hal';
@ModelConfig({
type: 'User',
endpoint: 'consumer'
})
export class User extends HalModel {}In the case above, fetching a list of users will trigger a request to mydomain.com/consumer. In the case the endpoint property is not specified in the ModelConfig decorator, the request will be made to mydomain.com/User.