I have a shared variable I want to declare in both component and I want the components to have shared values. I was wondering if this can be done.
A.html
...
<button (click)="sendInfo(a,b,c)" > </button>
...
B.html
...
<div *ngIf="showData" > {{loadData()}} </div>
...
A.component.ts
...
showData = false;
sendInfo(a: string, b:string, c:string) {
//calling webservice
showData = true;
}
...
B.component.ts
...
showData = false;
//when button from A.html clicked
showData = true;
So in B.component.ts I want to set the showData to true if the button from A.html is clicked.
How does B.component.ts know when A.component.ts has been changed?
How do I set this shared variable between two component?
EventEmitterto notify one component when the other fires the click event. But that assumes your components are in a parent-child