Angular 2+ call a function in a child component from its parent component

前端 未结 3 1638
余生分开走
余生分开走 2020-12-28 12:06

I\'d like to know the best way to do this, and if there are different ways. I\'m trying to call a function in a child component from its parent component. So if I have:

3条回答
  •  伪装坚强ぢ
    2020-12-28 12:43

    For calling a function of a child, you'll need @ViewChild. However, for showing/hiding a component, you are better off solving this within the template:

    
        
        
    
    

    No need for declaring a custom function hide().

提交回复
热议问题