Skip to content

Dependency Injection failing when a second decorator is in class #4994

Closed
@Jonatthu

Description

@Jonatthu
[x ] bug report => search github for a similar issue or PR before submitting

Current behavior
I have a class which I want to inject within it's constructor properties, they are classes too with @Injection() decorator,

@Injectable()
@remotedev({ name: 'STORE', onlyActions: true })
export class Store {
constructor(
    public alerts: AlertsStore,
    public client: ClientStore,
    public search: SearchStore,
    public searchListing: SearchListingStore
  ) {}

the other classes just have @Injectable() decorator and not a second decorator,
my index.ts to put the providers in the app module has the right order

export * from './alerts.store';
export * from './client.store';
export * from './search.store';
export * from './search-listing.store'
export * from './store';

and the providers looks like this

  providers: [
    AlertsStore,
    ClientStore,
    SearchStore,
    SearchListingStore,
    Store
  ],

and every property on the constructor is undefined. which is weird because on ionic 2 which is using @angular 2.2.1 is working normally without problems, but a project generated with ng cli is not working which is beta 32, and has angular ^2.4.0, so I'm not sure why this is working in ionic 2 and this not.

Expected behavior
Inject each class on the constructor

Minimal reproduction of the problem with instructions
https://github.com/Jonatthu/angular-dependency-injection-failing

What is the motivation / use case for changing the behavior?
Works fine on ionic 2 and this should work as well, without problems.

  • Angular version: 2.0.X
    Angular CLI beta.32.2, ionic has angular 2.2.1 and @angular from angular-cli is 2.4.2

  • 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 ]

  • Language: TypeScript

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P5The team acknowledges the request but does not plan to address it, it remains open for discussionneeds: investigationRequires some digging to determine if action is neededtype: bug/fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions