Это зависит от того, как настроены ваши родительские компоненты и являются ли они одним и тем же компонентом.
Если это разные компоненты:
parent-component-1.ts
:
public class Parent1Component {
public checked: boolean;
constructor() {
checked = true;
}
}
parent-component-2.ts
:
public class Parent2Component {
public checked: boolean;
constructor() {
checked = false;
}
}
Если они представляют собой один и тот же компонент, вам необходимо выполнить что-то вроде следующего:
parent-component.ts
:
public class ParentComponent {
@Input()
checked: boolean;
}
HTML:
<parent-component [checked]="true"></parent-component><!-- First -->
<parent-component [checked]="false"></parent-component><!-- Second -->