Trying to get my head around @Input and @Output and was hoping for an indications as to how my approach is wrong.
In the app.component PARENT COMPONENT I have the following
@Output() dateChanged = new EventEmitter();
dateSelected:any;
onDateSelected() {
this.dateSelected = this.yearValue + "|" + this.monthValue;
console.log(this.dateSelected);//is selected and prints out to console
this.dateChanged.emit(this.dateSelected);
}
this is the html
<div>
<!--app.component.html-->
<app-expenses (dateChanged)="onDateSelected($event)"></app-expenses>
</div>
CHILD COMPONENT In the child(ExpensesComponent ) component is as follow
@Input() dateChanged: any;
onDateSelected(e) {
console.log(e);//doesnt reach this point
}
onDateSelected doesn't fire of What would be a good way of passing this date value to the child?
Thanks
<app-expense>might be child and<app-component>might be parent but then your question doesn't make sense. If the child emits the event why would you wantonDateSelectedbe called on the child when the event is received.