angular6:注入服务时,实际注入的服务不是我请求的服务

时间:2018-10-04 06:52:13

标签: angular typescript oop

以下是我创建的服务:

HttpSiteLangService.ts

@Injectable({providedIn: 'root'})
export class HttpSiteLangService extends HttpSiteService<SiteLangConfigEntity> {...

HttpSiteService.ts

@Injectable({providedIn: 'root'})
export class HttpSiteService<E> extends HttpApiConfigService<E> {...

HttpApiConfigService.ts

@Injectable({providedIn: 'root'})
export class HttpApiConfigService<E> extends HttpApiService {...

HttpApiService.ts

@Injectable({providedIn: 'root'})
export class HttpApiService {

  constructor(private httpClient: HttpClient) {
  }
...

然后我尝试将HttpSiteLangService注入组件:

export class SiteLangListComponent implements OnInit {
  constructor(public httpService: HttpSiteLangService) {
    console.log(httpService)
  }
...

但是注入是HttpApiService,而不是HttpSiteLangService console log image

0 个答案:

没有答案