Within the User component TypeScript file:
user:User;
constructor(private authService:AuthService) {}
ngOnInit(): void {
this.authService.user.subscribe((userVal) => {
this.user = userVal;
console.log(this.user);
});
}
In the User component HTML file:
<div class="container mt-3 ">
<app-user-detail [userData]="user"></app-user-detail>
</div>
Within the User detail component TypeScript file:
export class UserDetailComponent implements OnChanges {
@Input() userData: User;
constructor() {}
ngOnChanges() {
console.log(this.userData)
}
}
I am encountering an issue where I am able to access the value of "this.user" in the User component TypeScript file, but it is coming up as undefined in the User detail component TypeScript file. Why might this be happening?