I have a parent component with the following markup
<div class="row">
<div class="col-xs-12">
<router-outlet>
</router-outlet>
</div>
</div>
I need to set a input property to the component that will be rendered based on the path. Clearly I cannot use the HTML markup to do so.
I cannot use the component resolver as well because my child components extend the parent component to reuse common methods. Webpack complains of circular dependency if I import the child component in the parent class.
In a nutshell, Child Component HTML
<button (click)="dosomething()"></button>
<span>{{sample}}</span>
Child Component TS
@Input() sample: number;
class Child extends parent{
}
Parent Component TS
class Parent{
stateVariable: number;
protected dosomething(){
stateVariable++;
// I need to then pass the state variable to the child component, in this case, the `sample` variable
}
}
This setup works when I have the child component tag instead of a router outlet. Is there any way, i could achieve this?