Angular2 DI does not work for ToDo example.

Created on 16 November 2016, about 8 years ago
Updated 12 July 2023, over 1 year ago

Seems like something is wrong with components bootstrapping as ng2_todo example fails to load with this exception:

Unhandled Promise rejection: Can't resolve all parameters for Ng2Todo: (?). ; Zone: ; Task: Promise.then ...

The reason is NG2 DI system cannot inject service TodoStore mentioned in Ng2Todo components' constructor:

    constructor(todoStore: TodoStore) {
        this.todoStore = todoStore;
    }

If I it's told manually what should be injected, example works fine:

    constructor(@Inject(TodoStore) todoStore: TodoStore) {
        this.todoStore = todoStore;
    }
🐛 Bug report
Status

Closed: outdated

Component

Code

Created by

🇷🇺Russia potop

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024