Angular `Injector` is not helping with circular dependency -
i've got circular dependency in services in angular (v4, using cli). understand circular dependencies should avoided; assume sake of argument can't influence that.
i've read many examples suggest using injector solve this. in case, isn't working - i'll still can't resolve parameters myservice... error.
even if create method never called in offending service this:
import { injectable, injector } '@angular/core'; import { myservice } '../my.service'; @injectable() export class someservice{ constructor(private injector:injector){} test() {//i don't call anywhere settimeout(() => this.injector.get(myservice).dostuff()); } } ...it still generate error. if comment out 1 line in test() method, works.
i using someservice same way - called using injector.get - injector.get call thing making circular dependency in either direction.
why working many people still error? related use of angular cli somehow? ...or changed angular 4?
this plunker helps demonstrate issue. please understand taken large application , minimal example, itself, demonstrates poor design - exposes issue.
Comments
Post a Comment