2017-10-16 33 views
2

使用@ngrx/effects v4.0.5和Angular v4.4.4。ngrx EffectsModule使得Http服務未定義

當我在app.module.ts中導入EffectsModule時,Http服務變得未定義。

一些代碼:

// app.module.ts 
import { BrowserModule, Title } from '@angular/platform-browser'; 
... 
import { HttpModule, Http } from '@angular/http'; 
... 
import { EffectsModule } from '@ngrx/effects'; 
import { AuthenticationModule } from './authentication/authentication.module'; 
import { MyEffects } from './myEffects.ts' 
... 

@NgModule({ 
    declarations: [ 
    AppComponent 
    ], 
    imports: [ 
    BrowserModule, 
    HttpModule, 
    ... 
    AuthenticationModule, 
    StoreModule.forRoot(reducers), 
    EffectsModule.forRoot([MyEffects]) 
    ] 
    ... 
}) 
export class AppModule { } 

請注意:MyEffects不以任何方式認證功能有關。

當我使用我可以在我的應用程序中使用的第一件事,登錄按鈕,我叫AuthenticationService.signIn,進而調用它的HTTP實例this.http.post(...

而且this.http是不確定的(有一個錯誤信息,看着它通過調試,並發現它未定義 - this不是不確定的,具有http屬性,該屬性未定義)

如果我註釋掉EffectsModule.forRoot([MyEffects]),HTTP服務「再次出現」,並在作品中的標誌。

請注意,MyEffects與身份驗證功能沒有任何關係。

回答

0

升級@angular/包從4.4.44.4.5解決了這個問題O_O」