简体   繁体   中英

BSModelservice callback function returning error. I am using angular 6 and ngx-bootstrap/modal

I am getting below exception.

ERROR TypeError: this.callBackOnSave.emit is not a function

Child Component

@Input() showDeleteBtn: boolean = true;
@Input() showGrid: boolean = true;
@Output() callBackOnSave: EventEmitter<null> = new EventEmitter();

this.callBackOnSave.emit();

Parent component

callBackOnSave(){
  console.log("got it***");
}

const initialState = {
  showDeleteBtn: false,
  showGrid: false,
  callBackOnSave: 'callBackOnSave()'
};

this.modalService.show(ScheduleComponent, {class: 'modal-md',  initialState});

Can anyone faced this issue. Please advice.

It seems you are keeping this statement this.callBackOnSave.emit(); outside of function. I don't think you will be doing this blunder but wondering by looking at your question. If yes then move inside the method if not then share the more code.

How does your Parent component's template look? it should have something like

<app-child-component (callBackOnSave)="callBackOnSave($event)">...</app-child-componen>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM