question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Angular2 UpgradeComponent missing $injector

See original GitHub issue

I’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

screen shot 2016-11-18 at 12 01 42

Upon closer inspection… Line 97 of upgrade_component.js is undefined: screen shot 2016-11-18 at 12 02 59

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:closed
  • Created 7 years ago
  • Reactions:8
  • Comments:20 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
petebacondarwincommented, Dec 20, 2016

If you are using upgrade/static then you should only move the AppComponent to the entryComponents and not put anything inside ngDoBootstrap. The Angular 1 app will be responsible for instantiating the downgraded AppComponent

1reaction
sebek64commented, Jan 3, 2017

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular2 UpgradeComponent missing $injector
3 Answers 3 · I am trying to UPGRADE the Angular1 component to Angular2 though because the majority of our code base is...
Read more >
UpgradeComponent - Angular
A helper class that allows an AngularJS component to be used from Angular. ... constructor(elementRef: ElementRef, injector: Injector) { // We must pass...
Read more >
[Solved]-angular2-jwt missing authorization in header-angular.js
Coding example for the question angular2-jwt missing authorization in ... Angular2 UpgradeComponent missing $injector · Remove Authorization Header for some ...
Read more >
Upgrade from AngularJS to Angular 2 | by Gökhan Sari
After we decided to upgrade our app from AngularJS to Angular 2 the whole process was not easy. ... We might want to...
Read more >
Angular 2 UI-Grid - Prasanna Kumar Pattam
As you know currently (Jan 2017) UI-Grid is not supported in Angular 2 and there is no other data table that provides the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found