タイププロバイダConnectionBackend
は、角度2.0.0-rc.5
から2.0.0
にアップグレードした後は機能しなくなりました。2番のリリースでConnectionBackendが動作しませんか? XHRBackendはどのように提供しますか?
私はプロバイダのリストに入れます。私はVisual Studioのコードからこのエラーを受け取ります。
[ts]引数 '{bootstrap:typeof AppComponent [];宣言:(TypeofLoginComponent | typeof EmailLoginCompo ... 'は' NgModule '型のパラメータに割り当てられません。 プロパティ'プロバイダ 'の型は互換性がありません。'(any [] | HttpModule | typeof Location | typeof AuthStore | (TypeProvider | ValueProvider | ExistingProvider | ExistingProvider |任意の[])[] ' タイプ' any [] | typeof HttpModule | typeof Location | typeof AuthStore | typeof TypeProvider | ValueProvider | ClassProvider | ExistingProvider |任意の[] ' タイプ' Typeof ConnectionBackend 'タイプを' TypeProvider | ValueProvider | ClassProvider | ExistingProvider | FactoryProvider | 'に割り当てることはできません。任意の[] ' ' typeof ConnectionBackend 'はタイプに割り当てできません 'どれか[]'。 プロパティ 'typeof ConnectionBackend'に 'push'プロパティがありません。
私はchangelogを見ましたが、ここに該当するものは表示されません。私は、たとえばHTTP_PROVIDERS
がHttpModule
に置き換えられていたことに気付きましたが、これは変更履歴にあり、全体の参照がなくなっていました。これははるかに見知らぬ人です。
XHRBackendを提供するために、角度2のリリース版で使用することは何ですか?
これは、関係するすべてのコードの付録のようなもの、です。質問部分は既に完成しています:
ここは私のNGModuleです。 ConnectionBackend
行がコメントアウトされた状態で、私のアプリケーションは正常に動作します(Httpオブジェクトを提供する必要がある場合は除外します)。
@NgModule({
bootstrap: [ AppComponent ],
declarations: [
AppComponent,
LoginComponent,
EmailLoginComponent,
EmailLoginCodeComponent,
ErrorComponent,
ExampleComponent,
],
imports: [
BrowserModule,
routing,
],
providers: [
appRoutingProviders,
HttpModule,
Location,
AuthStore,
RequestInterceptor,
ResponseInterceptor,
ConnectionBackend, // THIS IS THE PROBLEM LINE
{
provide: Config,
deps: [XHRBackend, RequestOptions],
useFactory: (
backend: XHRBackend,
defaultOptions: RequestOptions
) => {
let config = new Config(new Http(backend, defaultOptions));
// I hope this promise finishes
let promise: Promise<Config> = config.load().then(response => config);
return config;
},
},
{
provide: PanelGuidStore,
useFactory: (
() =>
new PanelGuidStore()
),
},
Locator,
{
provide: AuthService,
// Factory for AuthService
// use standard http here to avoid circular references
// (as well as pointless attempts to put Auth tokens inside Auth requests)
deps: [XHRBackend, RequestOptions, AuthStore, Config, Locator, PanelGuidStore],
useFactory: (
backend: XHRBackend,
defaultOptions: RequestOptions,
authStore: AuthStore,
config: Config,
locator: Locator,
panelGuidStore: PanelGuidStore
) =>
new AuthService(
new Http(backend, defaultOptions), authStore, config, locator, panelGuidStore
),
},
{
provide: Http,
// Factory for Http
// Use custom http provider to inject access tokens and deal with access token expiry
deps: [XHRBackend, RequestOptions, Location, RequestInterceptor, ResponseInterceptor],
useFactory: (
backend: XHRBackend,
defaultOptions: RequestOptions,
location: Location,
requestInterceptor: RequestInterceptor,
responseInterceptor: ResponseInterceptor,
authService: AuthService) =>
new AuthHttpProvider(
backend, defaultOptions, requestInterceptor, responseInterceptor
),
},
],
})
これは、Visual Studioのコードは、それが "プロバイダ" のパラメータですについて言いたいことです:
(プロパティ)プロバイダ:(任意の[] | typeof演算HttpModuleを| typeofの場所| typeofのあるAuthStore | typeof演算RequestInterceptor | typeof演算ResponseInterceptor | { [X:数]:未定義; が提供する:typeof演算コンフィグ; DEPS:(typeof演算XHRBackend | typeof演算のRequestOptions)[]; useFactory:(バックエンド:XHRBackend、defaultOptions:RequestOptions)=>コンフィグ; } | { [x:数値]:未定義。 提供:typeof PanelGuidStore; useFactory:()=> PanelGuidStore; | } |タイプロケーター| { [x:number]:未定義。 は、typeof AuthServiceを指定します。 deps:(typeof XHRBackend | typeof AuthStore | typeof Config |ロケータのタイプ| typeof PanelGuidStore)[]; (バックエンド:XHRBackend、defaultOptions:RequestOptions、authStore:設定:設定、ロケータ:ロケータ、panelGuidStore:PanelGuidStore)=> AuthService; | } | { [x:number]:未定義。 提供:タイプのHttp; deps:(XHRBackendのタイプ| typeof RequestOptions | typeof Location | typeIndeceptor | ResponseInterceptorのタイプ)[];useFactory :(バックエンド:XHRBackend、defaultOptions:RequestOptions、場所:Location、requestInterceptor:RequestInterceptor、responseInterceptor:ResponseInterceptor、authService:AuthService)=> AuthHttpProvider; })[]
としてそれを追加しないと、 'ConnectionBackend'は単なるインタフェースです。これは 'XHRBackend'が実装するインタフェースです。 'ConnectionBackend'が必要で、' XHRBackend'が実装です。だから、あなたは 'ConnectionBackend'プロバイダを取り出すことができます。 –
取り出したときにランタイムエラーが発生しますか? –
@peeskilletええ。 "XHRバックエンドのプロバイダがありません"。私が 'XHRBackend'を直接提供しようとすると、" BrowserXhrのプロバイダがありません "というメッセージが表示され、私が最後に見つけられないウサギの穴ができます(次はResponseOptionsのプロバイダがないと思います)。 –