I'm starting under TypeScript, I have a boolean displayReport variable in the component home.component.ts. I want to get the value of this variable in another component series-list.component.ts.
public displayReport: boolean = false;
public viewReport(): void {
console.log(this.displayReport);
this.displayReport = !this.displayReport;
}
Is it possible ?
///////////////////////////////EDIT ///////////////////////:
Here is what I did:
in the home.component.ts component:
constructor(
private studyService: StudyService
) { }
public viewReport(): void {
console.log('displayReport : ' + this.studyService.displayReport);
this.studyService.displayReport = !this.studyService.displayReport;
}
in the series-list.component.ts component:
constructor (private studyService: StudyService) { }
in the service study.service.ts:
public displayReport: boolean = false;
But when I do this in series-list.component.html :
<div *ngIf="this.studyService.displayReport"> </div>
I do not get the value of this.studyService.displayReport variable. I have this error : Unresolved variable studyService
How should I do ?