I am using the maven plugin to generate angular client for spring rest services.
I have a rest service called UserResources. Here is the generated code :
export interface HttpClient {
request<R>(requestConfig: { method: string; url: string; queryParams?: any; data?: any; copyFn?: (data: R) => R; }): RestResponse<R>;
}
export class UserResourcesClient {
constructor(protected httpClient: HttpClient) {
}
...
I created an implementation for the interface HttpClient in a seprate file :
@Injectable()
export class HttpClientImpl implements HttpClient {
request<R>(
requestConfig: {
method: string;
url: string;
queryParams?: any;
data?: any;
copyFn?: (data: R) => R;
}
): RestResponse<R> {
return null;
}
}
In my app.module.ts I declared HttpClientImpl
as a provider
providers: [
HttpClientImpl
]
The code compiles but doesn't work. The error is : Unhandled Promise rejection: Can't resolve all parameters for UserResourcesClient: (?). ; Zone: <root> ; Task: Promise.then ; Value: Error: "Can't resolve all parameters for UserResourcesClient: (?)."
It seems that angular doesn't use HttpClientImpl
when there is a reference to HttpClient
If you can help
Thank you