Skip to content
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: Cannot read property 'getOptional' of undefined(…) #42

Closed
kisdaniel opened this issue Feb 22, 2016 · 8 comments
Closed

Error: Cannot read property 'getOptional' of undefined(…) #42

kisdaniel opened this issue Feb 22, 2016 · 8 comments

Comments

@kisdaniel
Copy link

I have tried the ng2-translate, but I at runtime when it tries to use TranslateService:

/// <reference path="../../../../../../node_modules/angular2/platform/browser.d.ts"/>
import {bootstrap}    from 'angular2/platform/browser'
import {HTTP_PROVIDERS} from 'angular2/http';
import {TranslateService} from 'ng2-translate/ng2-translate';
import {HomeControllerApp} from './component-home-controller-app';

bootstrap(HomeControllerApp, [
    HTTP_PROVIDERS,
    TranslateService
]);```

it throws an error:

```Error: Cannot read property 'getOptional' of undefined(…)run @ angular2-polyfills.js:138zoneBoundFn @ angular2-polyfills.js:111lib$es6$promise$$internal$$tryCatch @ angular2-polyfills.js:1511lib$es6$promise$$internal$$invokeCallback @ angular2-polyfills.js:1523lib$es6$promise$$internal$$publish @ angular2-polyfills.js:1494lib$es6$promise$$internal$$publishRejection @ angular2-polyfills.js:1444(anonymous function) @ angular2-polyfills.js:243run @ angular2-polyfills.js:138zoneBoundFn @ angular2-polyfills.js:111lib$es6$promise$asap$$flush @ angular2-polyfills.js:1305```

package.json dependencies:

"devDependencies": {
"grunt": "~0.4.5",
"grunt-cli": "~0.1.13",
"grunt-contrib-copy": "~0.8.1",
"i18next-client": "~1.11.0",
"jquery": "~2.2.0",
"knockout": "~3.4.0",
"log4js": "~0.6.27",
"requirejs": "~2.1.20",
"sockjs": "~0.3.15",
"typescript": "^1.7.3"
},
"dependencies": {
"bootstrap": "3.3.5",
"font-awesome": "4.5.0",
"angular2": "2.0.0-beta.0",
"es6-promise": "3.0.2",
"es6-shim": "0.33.13",
"ng2-translate": "1.7.3",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.0",
"systemjs": "0.19.6",
"zone.js": "0.5.13"
}

@ocombe
Copy link
Collaborator

ocombe commented Feb 22, 2016

Hello,
this has nothing to do with ng2-translate, see: angular/angular#5614

@ocombe ocombe closed this as completed Feb 22, 2016
@guillaumeleone
Copy link

Same problem.

I don't understand, because in this post angular/angular#5755, it say there is a problem with es6-shim lib.

But in your showcase project, you use this lib.

@ocombe
Copy link
Collaborator

ocombe commented Mar 20, 2016

Maybe it's a question of version of the libs?
If you can make a project with the problem I'll check it out.

@guillaumeleone
Copy link

Oh thank you. Here an example with this problem: https://github.com/guillaumeleone/ng2-cli-translate
It happened when I added TRANSLATE_PROVIDERS in bootstrap file.
(The template was generated with angular-cli)

@qsahmed
Copy link

qsahmed commented Apr 11, 2016

I have the same issue,

import {HTTP_PROVIDERS} from 'angular2/http';
import {TRANSLATE_PROVIDERS} from 'ng2-translate/ng2-translate';
import {bootstrap} from 'angular2/platform/browser';
import {Application} from './app';
import {ReviverService} from "../service/reviver";

bootstrap(Application, [HTTP_PROVIDERS, TRANSLATE_PROVIDERS, ReviverService]);

ng2_translate_1.TRANSLATE_PROVIDERS is undefined.

@ocombe
Copy link
Collaborator

ocombe commented Apr 11, 2016

@qsahmed check the version of ng2-translate that you use :) the last one is 1.11.0

@qsahmed
Copy link

qsahmed commented Apr 11, 2016

Thanks for the quick reply.
I am using 1.11.0
"karma-phantomjs-launcher": "^0.1.2", "ng2-translate": "^1.11.0", "phantomjs": "^1.9.8",

@kemsky
Copy link

kemsky commented Apr 28, 2016

This error message is a consequence, original error is that injector could not resolve dependency. Almost impossible to trace unresolved component without putting console.logs into framework code (_constructDependencies).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants