I have created a user photo component
which takes an @Input()
value, this value is the userId. If the value is passed in then I retrieve information from Firebase
linking to this userId, if it doesn't then I do something else.
My user-photo component
import { Component, OnInit, OnDestroy, Input } from '@angular/core';
@Component({
selector: 'user-photos',
templateUrl: './user-photos.component.html',
styleUrls: ['./user-photos.component.css']
})
export class UserPhotoComponent implements OnInit {
@Input() userId: string;
constructor() {
console.log('userId is:',this.userId);
}
ngOnInit() {
}
ngOnDestroy() {
}
}
As you can see I have declared the userId as @Input()
, now on my edit-profile component
I have the following:
<user-photos [userId]="TestingInput"></user-photos>
Now the User Photo component gets rendered as I see the h1
tag appearing, however the userId is always undefined ?
No errors are appearing in the developer console, so I'm not entirely sure what I've done wrong.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…