angular2 call function of parent component

前端 未结 4 885
有刺的猬
有刺的猬 2021-01-30 01:33

I have an app where I have an upload component where I can upload a file. It is embedded in the body.component.

On upload, it should use a function (e.g.

4条回答
  •  情深已故
    2021-01-30 01:55

    Below is worked for me in latest

    Angular5

    class ChildComponent {
      @Output() myEvent = new EventEmitter();
    
      callParent() {
        this.myEvent.emit('eventDesc');
      }
    }
    

    In ParentTemplate's template

提交回复
热议问题