EXCEPTION: No provider for UserData! (LoginPage -> UserData)

Unfortunately it seems like it is indeed by design and I’m not holding my breath hoping for it to change.

There’s an ongoing discussion about it here: https://github.com/angular/angular/issues/5622

A sort of workaround to decouple service from inner dependencies could be to export a constant array (export constant SOME_SERVICE = [SomeService, OtherServiceUsedBySomeService …] and add that to component’s providers array instead.

I guess that is the same pattern already used in Angular2 when considering HTTP_DIRECTIVES etc

2 Likes