How to call header component function to another component in angular 2?

后端 未结 5 949
别跟我提以往
别跟我提以往 2021-01-22 07:24

I want to call showmodel(displayType) from another compoent.How to call header component function to another component?

header.compoent.ts

5条回答
  •  猫巷女王i
    2021-01-22 08:03

    just use this code: in your component

    @ViewChild(HeaderComponent, { static: true }) headerComponent: HeaderComponent;

    and then use:

    this.headerComponent.anyheaderMethod();

    this will help definitly

提交回复
热议问题