1
votes

So here is my code, I do believe you can understand what I'm trying to accomplish with no additional explanations.

@Injectable()
export class Dispatcher {
}

@Injectable()
export class TodoStore {

    constructor(@Inject(Dispatcher) private dispatcher:Dispatcher){ 

    }
}

@Component({
    ...
      providers:[TodoStore,Dispatcher]
}
export class MyComponent{
    costructor(@Inject(TodoStore) private store:TodoStore) {}
}

I'm getting Uncaught Error: Can't resolve all parameters for TodoStore: (?). Any ideas, please

1
Do you need to write @Inject(Dispatcher) private dispatcher: Dispatcher? Wouldn't it be sufficient to just use private dispatcher: Dispatcher and private store: TodoStore in your constructors? - alex kucksdorf
yeah, I was trying this private store: TodoStore and it works as well, but not resolving current issue - Lunin Roman
@Inject and other decorators duplicate each other, there's no need to use them both. The code above should work. Something is behind the scenes that you didn't show. A fiddle/plunk that can replicate the issue is needed. - Estus Flask
I created a Plunkr to try your code and it works like a charm... - alex kucksdorf
Hm, which version are you using? - Lunin Roman

1 Answers

-1
votes

This should work, and it works for me. It is not possible to say why it doesn't work in your case, without the complete code and setup.

Two comments: constructor was misspelled, and @Inject(...) is unneeded.