NAR*_*EEN 3 translation angular
虽然使用ng2-translation软件包在angular2中进行动态转换,但我得到的错误如下:未处理的Promise拒绝:没有TranslateService的提供者!
zone.js:388Unhandled Promise rejection: No provider for TranslateService! ; Zone: <root> ; Task: Promise.then ; Value: NoProviderError {_nativeError: Error: No provider for TranslateService!
at NoProviderError.BaseError [as constructor] (http://l…, keys: Array[1], injectors: Array[1]} Error: No provider for TranslateService!
at NoProviderError.BaseError [as constructor] (http://localhost:4200/main.bundle.js:7039:34)
at NoProviderError.AbstractProviderError [as constructor] (http://localhost:4200/main.bundle.js:43876:16)
at new NoProviderError (http://localhost:4200/main.bundle.js:43907:16)
at ReflectiveInjector_._throwOrNull (http://localhost:4200/main.bundle.js:62960:19)
at ReflectiveInjector_._getByKeyDefault (http://localhost:4200/main.bundle.js:62988:25)
at ReflectiveInjector_._getByKey (http://localhost:4200/main.bundle.js:62951:25)
at ReflectiveInjector_.get (http://localhost:4200/main.bundle.js:62760:21)
at AppModuleInjector.createInternal (AppModule.ngfactory.js:263:72)
at AppModuleInjector.NgModuleInjector.create (http://localhost:4200/main.bundle.js:44784:76)
at NgModuleFactory.create (http://localhost:4200/main.bundle.js:44769:18)
Run Code Online (Sandbox Code Playgroud)
我知道这个问题现在已经很老了,但是对于那些在本页面上搜索相同问题的人,请仔细检查是否已在@NgModule providers数组中添加了该服务.
在我的情况下,我想在一个模块中导入一个自定义服务' AuthGuard ',并不断收到错误' 未处理的承诺拒绝:没有AuthGuard服务提供商 '.我对这个问题的解决方法是 -
@NgModule({
declarations: [
TicketListComponent,
TicketDetailComponent
],
imports: [
CommonModule,
RouterModule.forChild(appRoutes)
],
providers: [
AuthGuard
]
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9299 次 |
| 最近记录: |