我试图将 2 个值从子组件发送到父组件。事件正在发出 onSubmit 但对象未在父组件中接收值。
// 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);
}