I have a library with a component that has a provider, like so-
@Component({
selector: "lib-layer-list-widget",
templateUrl: "./layer-list-widget.component.html",
styleUrls: ["./layer-list-widget.component.css"],
providers: [LayerListWidgetService],
})
export class LayerListWidgetComponent {}
This component is being rendered in my angular project and
that service has methods I want to use from a component in my project.
example:
import {
LayerListWidgetService,
} from "my-lib";
@Component({
selector: "app-example",
templateUrl: "./app-example.component.html",
styleUrls: [],
})
export class AppExampleComponent {
constructor( private layerListWidgetService: LayerListWidgetService) {
let elements = this.layerListWidgetService.getLayerListElements();
}
}
Problem is- this is not working properly because the instance I refer to here is not the same as the one that was created as a provider to the component.
I tried to read the documentation and search around but I could not find a concrete answer.
Is there a way to access a component's provider (in a lib) from another component?