在之前的版本中,我提供了AuthHttp作为Fallows:
return bootstrap(<any>App, [
// These are dependencies of our App
...FORM_PROVIDERS,
...HTTP_PROVIDERS,
...ROUTER_PROVIDERS,
...ENV_PROVIDERS,
provide(AuthHttp, {
useFactory: (http) => {
return new AuthHttp(new AuthConfig({
tokenName: 'jwt'
}), http);
},
deps: [Http]
}),
provide(APP_BASE_HREF, {useValue : '/' })
]).catch(err => console.error(err));
但在RC4 +提供已弃用且弃用警告即将到来。 那么如何为以后的版本更改这些兼容性。
答案 0 :(得分:3)
提供更改为传递对象而不是函数:
return bootstrap(<any>App, [
// These are dependencies of our App
...FORM_PROVIDERS,
...HTTP_PROVIDERS,
...ROUTER_PROVIDERS,
...ENV_PROVIDERS,
{
provide: AuthHttp,
useFactory: (http) => {
return new AuthHttp(new AuthConfig({
tokenName: 'jwt'
}), http);
},
deps: [Http]
},
{
provide: APP_BASE_HREF,
useValue : '/'
}
]).catch(err => console.error(err));