I have this parent component
-person.component.html
<div>
<main>
<address-list (addressPresent)="setPersonInfo($event)"></address-list>
<company-list *ngIf="personInfo"></company-list>
</main>
</div>
-address-list.component.ts
addressExists: boolean;
@Output() addressPresent: EventEmitter<boolean> = new EventEmitter<boolean>();
updateAddress(value: boolean) {
this.addressPresent.emit(value);
}
ngOnInit(): void {
this.data();
}
data(): void {
...
...
this.personService.getPersonInfo(this.personId).subscribe((res => {
...
this.updateAddress(res.body.personInfo);
...
}))
}
-person.component.ts
personInfo: boolean;
setPersonInfo(value: boolean): void {
this.personInfo = value;
}
How do I pass the boolean value from address-list
component to person
component so that I can use it to enable or disable the company-list
component?
Implementation that I have done returns undefined
value for addressExists
variable when I log it inside ngOnInit()
.