I am adding ng2-translate to a project. When I add TranslateService I get:
Error: Cannot read property 'getOptional' of undefined(…)
My system config is setup properly but after hours of searching I can't find anything that helps me figure out what's wrong.
//angular
import {bootstrap} from "angular2/platform/browser";
import {Component,Inject,provide} from "angular2/core";
import {HTTP_PROVIDERS} from "angular2/http";
import {TranslateService,TranslateStaticLoader,TranslateLoader} from "ng2-translate/ng2-translate";
@Component({
selector: 'app',
directives: [TheApp],
template: '<the-app></the-app>'
})
class TT{
translate:TranslateService
constructor(@Inject(TranslateService) translate:TranslateService){
this.translate = translate;
....
}
....
}
bootstrap(TT,[
HTTP_PROVIDERS,
provide(TranslateLoader, {useClass: TranslateStaticLoader}),
TranslateService
]);
angular2.dev.js:353 TypeError: Cannot read property 'toString' of undefined angular2-polyfills.js:1243
Error: Cannot read property 'getOptional' of undefined(…)Zone.run @ angular2-polyfills.js:1243zoneBoundFn @ angular2-polyfills.js:1220lib$es6$promise$$internal$$tryCatch @ angular2-polyfills.js:468lib$es6$promise$$internal$$invokeCallback @ angular2-polyfills.js:480lib$es6$promise$$internal$$publish @ angular2-polyfills.js:451lib$es6$promise$$internal$$publishRejection @ angular2-polyfills.js:401(anonymous function) @ angular2-polyfills.js:123Zone.run @ angular2-polyfills.js:1243zoneBoundFn @ angular2-polyfills.js:1220lib$es6$promise$asap$$flush @ angular2-polyfills.js:262
<script src="es6-shim.min.js"></script>
<script src="es6-module-loader.js"></script>
<script src="system-polyfills.js"></script>
<script src="angular2-polyfills.js"></script>
<script src="system.src.js"></script>
<script src="Rx.js"></script>
<script src="angular2.dev.js"></script>
<script src="ng2-bootstrap.js"></script>
<script src="ng2-translate.js"></script>
<script src="router.js"></script>
<script src="http.js"></script>
<script>
System.transpiler = 'typescript';
System.config({
packages: {
ts: {
format: 'register',
defaultExtension: 'js'
}
},
map: {
moment: '/moment.js',
'ng2-translate/ng2-translate': '/ng2-translate.js'
}
});
System.import('ts/main')
.then(null, console.error.bind(console));
</script>
TypeError: Cannot read property 'getOptional' of undefined at runAppInitializers (localhost:8000/angular2.dev.js:12628:25) at PlatformRef.initApp (localhost:8000/angular2.dev.js:12603:21) at PlatformRef.application (localhost:8000/angular2.dev.js:12550:22) at Object.bootstrap (localhost:8000/angular2.dev.js:24805:64) at execute (localhost:8000/ts/main.js:118:23) at ensureEvaluated (localhost:8000/system.src.js:3197:26) at Object.execute (localhost:8000/system.src.js:3315:13) at doDynamicExecute (localhost:8000/system.src.js:708:25) at link (localhost:8000/system.src.js:910:20) at doLink (localhost:8000/system.src.js:562:7)