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

后端 未结 5 931
别跟我提以往
别跟我提以往 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条回答
  •  清酒与你
    2021-01-22 08:10

    make use of viewChild in your parent component.

    in your app component -

    @ViewChild(HeaderComponent) headerComponent : HeaderComponent;
    

    then use

    headerComponent.headerMethodName(); 
    

    any method from HeaderComponent you want to invoke.

提交回复
热议问题