I passed data prom parent to child
`<tag-editor[item]="item"></tag-editor>`
Item here has data
Child component:
export class TagEditorComponent implements OnInit, OnChanges {
@Input() private item: Tag;
ngOnInit() {
console.log(this.item)
}
ngOnChanges() {
console.log(this.item)
}
But i got only 2 undefined
.
How can i fix it?
//Try this :
import {OnInit, SimpleChanges, OnChanges} from '@angular/core';
export class TagEditorComponent implements OnInit, OnChanges {
@Input() private item: Tag;
ngOnInit() {
console.log(this.item)
}
ngOnChanges(changes : SimpleChanges) {
if(typeof changes['item'] !== 'undefined'){
console.log(this.item)
}
}