gpt4 book ai didi

angular - ngrx EffectsModule 使 Http 服务未定义

转载 作者:搜寻专家 更新时间:2023-10-30 21:59:34 25 4
gpt4 key购买 nike

使用 @ngrx/effects v4.0.5 和 Angular v4.4.4。

当我在 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 与身份验证功能没有任何关系。

最佳答案

@angular/包从4.4.4升级到4.4.5解决了问题O_O'

关于angular - ngrx EffectsModule 使 Http 服务未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46772864/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com