在子组件中发出事件时对象未在父组件中接收

Object is not receiving in parent component when event is emitted in child component

我试图将 2 个值从子组件发送到父组件 component.Event 发出 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);
}

您应该使用 $event 作为父 组件 .

事件发射器 处理程序的参数
<app-filter-panel (submitEvent)="eventrecive($event)"></app-filter-panel>
                                             ^^^^^^^  

对于 EventEmitter events 发出的值可用 $event.