I assume that your parent and child classes are in different files and that you import Child into the parent file so that you can put it in the directives Parent decorator (you donβt have to do this in your example, but otherwise the Child will not be created at all , which is clearly not the case).
In this case, you need to use forwardRef everything that is defined in the file of the parent class, which is used in the file of child classes, which should be loaded first, because it is imported into the parent class and, therefore, is not tied to anything defined later uploaded file (no workaround which forwardRef )
So,
import {forwardRef} from "angular2/core"; ... constructor(@Inject(forwardRef(()=>SF)) private a: A) {}
should work where
constructor(@Inject(SF) private a: A) {}
fails.
Sidenote: provide(SF, {useValue: A}) , where A is a reference to a class, not an instance, the smell is fishy. I will not reflect on what you are doing, but I will say that it is much more typical to see that useValue used with reference to the instance and useClass used with reference to the class.
source share