I have an abstract class where I mentioned all my http
calls and while extending it in child services throws error on compile time.
Can't resolve all parameters for MyService : (?).
baseservice.ts
import { HttpClient, HttpHeaders } from '@angular/common/http';
export abstract class BaseService{
constructor(private http: HttpClient){} //http undefined on compile time
get(){
return this.http.get()
}
}
myservice.ts
@Injectable()
export class MyService extends BaseService{
getSource() {
return this.get('api/Source')
}
}
If I added other injectTokens in constructor of abstract class this leads to not defined
error
constructor(private http: HttpClient, @Inject(APP_CONFIG) private appConfig: any | undefined) {}
Uncaught ReferenceError: http_1 is not defined
if I trying to add Options, it initialising the HttpClient and all working fine
HttpOptions = {
headers: new HttpHeaders({
'Authorization': `Bearer ${this.token}`
})
What is the reason behind this and how to over come this issue while creating instance HttpClient
without any InjectTokens
or httpOtions
.