Skip to content

angular/upgrade static $injector is undefined when upgrading ng1 service #14993

@Nevergonnachange

Description

@Nevergonnachange

I'm submitting a ... (check one with "x")

[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 cannot inject an upgraded ng1 service into a ng2 component. Because $injector is undefined.

Expected behavior
I can inject the upgraded ng1 service

Minimal reproduction of the problem with instructions
If I use an angular2 component as root (as described here: https://angular.io/docs/ts/latest/guide/upgrade.html#!#dividing-routes-between-angular-and-angularjs) I get the $injector issue (as shown in the plnkr bellow) ONLY if the "initial route (/login)" is an angular2 route. If I start with an angular1 route and then change to the angular2 route (/login) everything works fine.
https://plnkr.co/edit/mUvt7miMrOEyTyEk8ooX?p=preview

What is the motivation / use case for changing the behavior?
To use angular1 services within an angular2 context while gradually moving towards an angular2 application.

Please tell us about your environment:
OS: Windows 10
IDE: Webstorm
Package manager: NPM,
Build system: Webpack,
Webserver: webpack-dev-server

  • Angular version: 2.0.X
    2.4.1

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
    Chrome

  • Language: [all | TypeScript X.X | ES6/7 | ES5]
    Typescript 2.2.1

  • Node (for AoT issues): node --version =
    6.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions