-
-
Notifications
You must be signed in to change notification settings - Fork 572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error on bootstrap with TRANSLATE_PROVIDERS #120
Comments
I found a Solution: const TRANSLATE_PROVIDERS2: any = [ This constant works for me. |
The solution provided by @svenloe worked for me: no more error bootstrapping the application. But I got another error in the application main component constructor: the injected TranslateService is undefined. So the browser console shows: EXCEPTION: TypeError: Cannot read property 'query' of null Two questions:
Thanks in advance ! |
Hello @matthieubouvierthales for me ng2-translate works now with RC1. I have my constant in my main.ts and a constructor(private _translate: TranslateService). A Pipe: pipes: [TranslatePipe]. I set the _translate.setDefaultLang('en') and _translate.use('en'). My solution is a workaround ng2-translate should fix its constant. Your stacktrace complains about 'query'. I do not see a connection to ng2-translate in the stacktrace. Perhaps it is an other part of your app that does not work. |
Hello @svenloe, The query is a service property, and the "null" service here is the TranslateService (seen with breakpoints). |
Possible solution: System config: (notice System.config({
map: {
/* ... */
'ng2-translate': 'vendor/ng2-translate',
/* ... */
},
packages: {
/* ... */
'ng2-translate': {
format: 'cjs',
defaultExtension: 'js',
main: 'ng2-translate'
},
/* ... */
}
}) to vendor folder i am copying as |
I have moved to Angular-Cli and it works fine. |
Hello,
I use ng2-translate in my app version 2.1.0. After the update to Rc1 translate causes this error message:
system-polyfills.js:4 Error: Error: Invalid provider - only instances of Provider and Type are allowed, got: [object Object] at InvalidProviderError.BaseException [as constructor] (http://localhost:8080/ravgruppe-web/node_modules/@angular/core/src/facade/exceptions.js:17:23) at new InvalidProviderError (http://localhost:8080/ravgruppe-web/node_modules/@angular/core/src/di/reflective_exceptions.js:180:16) at eval (http://localhost:8080/ravgruppe-web/node_modules/@angular/core/src/di/reflective_provider.js:162:19) at Array.forEach (native) at _normalizeProviders (http://localhost:8080/ravgruppe-web/node_modules/@angular/core/src/di/reflective_provider.js:145:15) at eval (http://localhost:8080/ravgruppe-web/node_modules/@angular/core/src/di/reflective_provider.js:156:13) at Array.forEach (native) at _normalizeProviders (http://localhost:8080/ravgruppe-web/node_modules/@angular/core/src/di/reflective_provider.js:145:15) at eval (http://localhost:8080/ravgruppe-web/node_modules/@angular/core/src/di/reflective_provider.js:156:13) at Array.forEach
The translate.service is not provided. The typecheck fails.
The reflect-metadata version of Angular rc1 is 0.1.3 and the one of ng2-translate is 0.1.2.
main.ts file:
import {bootstrap} from '@angular/platform-browser-dynamic'; import {HTTP_PROVIDERS} from '@angular/http'; import {TRANSLATE_PROVIDERS, TranslateService, TranslatePipe, TranslateLoader, TranslateStaticLoader} from 'ng2-translate/ng2-translate'; import 'rxjs/Rx'; import {ROUTER_DIRECTIVES, ROUTER_PROVIDERS} from '@angular/router'; import {AppComponent} from './ravgruppe/app.component'; bootstrap(AppComponent, [HTTP_PROVIDERS,TRANSLATE_PROVIDERS, ROUTER_PROVIDERS]); //bootstrap(AppComponent, [HTTP_PROVIDERS, ROUTER_PROVIDERS]);
If I remove TRANSLATE_PROVIDERS bootstrap works but the pipes fail.
systemjs.config.js:
var map = { 'app': 'app', // 'dist', 'rxjs': 'node_modules/rxjs', 'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api', '@angular': 'node_modules/@angular', 'ng2-translate': 'node_modules/ng2-translate', 'angular2': 'node_modules/angular2' }; var packages = { 'app': { main: 'main.js', defaultExtension: 'js' }, 'rxjs': { defaultExtension: 'js' }, 'angular2-in-memory-web-api': { defaultExtension: 'js' }, 'ng2-translate': { defaultExtension: 'js' }, 'angular2': { defaultExtension: 'js' } };
Do you have an idea how I can fix the issue?
Yours
Sven
The text was updated successfully, but these errors were encountered: