Angular2 UpgradeComponent missing $injector
See original GitHub issueI’m submitting a …
[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
I was following the Upgrade documentation to upgrade an Angular1 Component to Angular2: https://angular.io/docs/ts/latest/guide/upgrade.html
When using @angular 2.2.1
’s UpgradeComponent
, it gives an error saying this.$injector is not found in upgrade_component.js
Upon closer inspection… Line 97 of upgrade_component.js
is undefined
:
Minimal reproduction of the problem with instructions
Minimal Demo is created using angular-cli
, with only one filed added: https://github.com/dolanmiu/angular2-upgrade-test
https://github.com/dolanmiu/angular2-upgrade-test/blob/master/src/app/chart/chart.component.ts
The corresponding .ts
file is here:
https://github.com/angular/angular/blob/master/modules/@angular/upgrade/src/aot/upgrade_component.ts#L121
What is the motivation / use case for changing the behavior?
I need to upgrade old existing Angular1 code into Angular2
Please tell us about your environment:
- Angular version: 2.2.1
- Browser: [all | Chrome]
-
Language: [all | TypeScript]
-
Node (for AoT issues):
node --version
= 6.9.1
Issue Analytics
- State:
- Created 7 years ago
- Reactions:8
- Comments:20 (3 by maintainers)
If you are using
upgrade/static
then you should only move theAppComponent
to theentryComponents
and not put anything insidengDoBootstrap
. The Angular 1 app will be responsible for instantiating the downgradedAppComponent
Well, and there is another scenario in which $injector is undefined.
https://plnkr.co/edit/eq8VXrAnMWExTDdZJEF6
When we inject an upgraded service (e.g. $rootScope) into a downgraded service (in this example, MyService) and inject MyService into a run() block, then MyService is constructed with $injector still undefined.