如何在angular7的整个模块中提供通用打字稿服务?

时间:2019-05-10 12:32:22

标签: typescript servicestack angular7

我想要

  

_findEpisodeService

可在我的整个app.module中使用。所以我需要在我的app.module的@NgModule的providers数组中提供它。问题是我不确定该怎么做。请帮忙!

// Generic service
export class ServicestackService<T> {
  constructor(private _auth: AuthenticationService, private _router: Router) {
    this._client.onAuthenticationRequired = this.onAuthenticationRequired;
  }
}

// service.ts
const req = new FindEpisode();
const _findEpisodeService = new ServicestackService<FindEpisode>(this.auth, this.router);

// App.module.ts
@NgModule({
providers: [
 {provide: JsonServiceClient, useValue: new JsonServiceClient('/')}
 ],
})

0 个答案:

没有答案