hi,
there is a library (ng generate library...) project called Warrior, there
is a component called warrior.component.ts
warriorComponent's constructor's parameter includes (private weapon: Weapon)
Weapon is also defined in the library project and is decorated with
@Injector
@Injector()
export class Weapon{...
In the root application:
I have a class called Sword that extends Weapon (from library project:
Warrior)
export class Sword extends Weapon{
in the app.module.ts in the providers i added { provide: Weapon, useClass:
Sword }
However, upon navigating to the url that houses that component, i get the
following error:
Error: StaticInjectorError(AppModule)[WarrriorComponent -> Weapon]:
StaticInjectorError(Platform: core)[WarrriorComponent -> Weapon]:
NullInjectorError: No provider for Weapon!
All in am trying to do is to use the DI and following the inversion of
control pattern to supply the weapon to the warrior defined in the library
separate from the app, where the implementation of weapon is outside of
that library project. I am using the Weapon as the interface (even though
i have to define it as a class) and use the Sword at its implementation.
Also to I am using routes to navigate to that component without lazy
loading
if i update the app.modules constructor to include (private weapon: Weapon)
and step through it in the browser i can see the di resolves weapon to
sword. however, when it tries to load the warriorComponent that also has
(private weapon: Weapon) in it's constructor, i get the above mentioned
error.
I am complete loss here, any help will be appriciated.
Thanks
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.