2016-11-02 6 views
3

Während der Übersetzung dynamisch in angular2, mit Hilfe von ng2-Übersetzungspaket bekomme ich Fehler wie: Unhandled Promise Ablehnung: Kein Anbieter für TranslateService!Unbehandelte Promise-Zurückweisung: Kein Provider für 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) 
+0

Haben Sie es an die App-Modul hinzufügen? – FacundoGFlores

+0

ja ich habe hinzugefügt –

Antwort

0

TranslateModule.forRoot() zu Ihrem imports: Abschnitt in Ihrem Stamm NgModule hinzufügen.

5

Ich weiß, diese Frage ist ziemlich alt jetzt, aber für alle, die das gleiche Problem, überprüfen Sie auf dieser Seite Suche kommt, dass Sie den Service in @NgModuleAnbieter Array hinzugefügt haben.

In meinem Fall wollte ich einen benutzerdefinierten Dienst in einem Modul ‚AuthGuard‘ importieren, und hielt den Fehler ‚Unhandle Versprechen Ablehnung: Kein Anbieter für AuthGuard Service‘ bekommen. Mein Fix für das Problem war-

@NgModule({ 
    declarations: [ 
     TicketListComponent, 
     TicketDetailComponent 
    ], 
    imports: [ 

     CommonModule, 
     RouterModule.forChild(appRoutes) 

    ], 
    providers: [ 
     AuthGuard 
    ] 
}) 
1

Ich hatte ein ähnliches Problem, und es stellte sich heraus, weil ich CommonModule 'importierte aber nicht ‚BrowserModule‘ in meinem app.module.ts importieren.

I entfernt ‚CommonModule‘ und setzen ‚BrowserModule‘ in der Liste der Einfuhr und das Problem behoben ....

Verwandte Themen