Injected dependency is undefined when extending BaseRequestOptions

后端 未结 2 1363
面向向阳花
面向向阳花 2021-01-22 01:15

I am extending BaseRequestOptions in Angular2 to add headers for each request. I also have a Config class that supplies key/value pairs based on the do

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-22 01:51

    This is actually much easier than peeskillet's answer. When defining your provider also specify the dependencies for that provider so it would look like:

    providers: [
    {
        provide: RequestOptions,
        useClass: DefaultRequestOptions,
        deps: [Config]
    };
    

提交回复
热议问题