最佳答案
Trying to get the component's @Input
value in constructor
or ngOnInit
. But it is coming as undefined
all the time.
I updated the hero plunker with console.log
to show the issue (beta angular).
http://plnkr.co/edit/dseNM7OTFi1VNG2Z4Oj5?p=preview
export class HeroDetailComponent implements OnInit {
constructor(){
console.log('hero', this.hero)
}
public hero: Hero;
ngOnInit() {
console.log('hero', this.hero)
}
}
What am I doing wrong here?