That breaks the whole purpose of making two components in the first place. Since you are making one dependant on the other you can't reuse them separately, might as well make them one.
Create a parent that holds both components inside and the info they both need and set that info to each children component as @Input
s:
https://angular.io/docs/ts/latest/api/core/Input-var.html
some raw example:
<component-A (modeSelected)="selectedMode==$event"/>
<component-B [mode]="selectedMode" />
or:
<component-A #modeSelector/>
<component-B [mode]="modeSelector.selectedMode" />
()
means output, []
means input.
In the first example selectedMode
is a property of a parent controller that holds both A and B components inside. In the second example selectedMode
is a property of component A.