Issue Resolved.
Implemented a new data service that extends DefaultDataService
Located in src/app/store/entity-store-module.ts
import {EntityDataService} from '@ngrx/data';
import {NewDataService} from './new-data-service';
import {NgModule} from '@angular/core';
@NgModule({
providers: [
NewDataService
]
})
export class EntityStoreModule {
constructor(
entityDataService: EntityDataService,
newDataService: NewDataService,
) {
entityDataService.registerService('Item', newDataService);
}
}
File path: src/app/store/new-data.service.ts
import {
DefaultDataService,
DefaultHttpUrlGenerator,
DefaultPluralizer, HttpMethods,
HttpUrlGenerator,
Logger,
} from '@ngrx/data';
import {Injectable} from '@angular/core';
import {Item} from '../items/models/item.model';
import {HttpClient} from '@angular/common/http';
import {pluralNames} from './entity-metadata';
import {Observable} from 'rxjs';
@Injectable()
export class NewDataService extends DefaultDataService<Item> {
constructor(
http: HttpClient,
httpUrlGenerator: HttpUrlGenerator,
logger: Logger
) {
logger.log(http, httpUrlGenerator);
const url = new DefaultHttpUrlGenerator(new DefaultPluralizer([pluralNames]));
url.registerHttpResourceUrls({Label: {entityResourceUrl: 'item', collectionResourceUrl: 'items'}});
super('Item', http, url);
}
protected execute(method: HttpMethods, url: string, data?: any, options?: any): Observable<any> {
if (method === 'POST') {
url = 'client/' + 2 + '/item'; // where 2 will be replaced dynamically
}
return super.execute(method, url, data, options);
}
}