Typescript 如何在angular7的整个模块中提供通用类型脚本服务?
我想要 _金融机构 可在我的应用程序模块中使用。所以我需要在app.module的@NgModule的providers数组中提供它。问题是我不知道怎么做。请帮忙Typescript 如何在angular7的整个模块中提供通用类型脚本服务?,typescript,
servicestack,angular7,Typescript,
servicestack,Angular7,我想要 _金融机构 可在我的应用程序模块中使用。所以我需要在app.module的@NgModule的providers数组中提供它。问题是我不知道怎么做。请帮忙 // Generic service export class ServicestackService<T> { constructor(private _auth: AuthenticationService, private _router: Router) { this._client.onAuthent
// 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('/')}
],
})
//通用服务
导出类ServicestackService{
构造函数(私有身份验证:AuthenticationService,私有路由器:路由器){
this.\u client.onAuthenticationRequired=this.onAuthenticationRequired;
}
}
//服务台
const req=new FindEpisode();
const\u findEpisodeService=新服务堆栈服务(this.auth,this.router);
//App.module.ts
@NGD模块({
供应商:[
{provide:JsonServiceClient,useValue:newjsonserviceclient('/')}
],
})