Can anyone help me with passing a boolean value from one service to another service file in Angular? I'm encountering an issue where the boolean value is showing as undefined. I haven't been able to find any examples or documents related to this. Any guidance would be greatly appreciated.
I need to pass a boolean value from the following file:
Auth.service.ts
public Data: boolean;
passValueFunction(){
this.Data = true;
}
In the second service file, I need to access the boolean value (Data variable in auth.service file) from the auth service file.
second.service.ts
constructor(private authService: AuthService){
}
ngOnInit(){
console.log(this.authService.Data);
}
In the second service file, I'm not receiving the Data value as true. I want this.authService.Data to be true in the second service file. I'm unsure why this.authService.Data is being shown as undefined.