I trying to send the 2 values to parent component from child component.Event is emitting onSubmit but the object is not receiving values in parent component.
// child component
@Output() submitEvent = new EventEmitter < object > ();
//here I am emitting the values
onSubmit() {
const startdate = moment(this.angForm.get('start_date').value).format('YYYY-MM-DD HH:mm:ss');
const enddate = moment(this.angForm.get('end_date').value).format('YYYY-MM-DD 23:59:00');
const obj = {
startdate: moment(this.angForm.get('start_date').value).format('YYYY-MM-DD HH:mm:ss'),
enddate: moment(this.angForm.get('end_date').value).format('YYYY-MM-DD 23:59:00')
}
this.submitEvent.emit({
startdate,
enddate
});
}
//parent component
<app-filter-panel (submitEvent)="eventrecive(dateobj)"></app-filter-panel>
eventrecive(dateobj) {
console.log(dateobj);
}
You should use $event
as parameter for event emitter handler in the parent component.
<app-filter-panel (submitEvent)="eventrecive($event)"></app-filter-panel>
^^^^^^^
For EventEmitter
events the emitted value is available as $event
.