How to call router outlet child component method from parent comonent

前端 未结 10 1983
甜味超标
甜味超标 2020-12-18 19:42

I am new to angular2


    

I have a button in parent component, if

10条回答
  •  爱一瞬间的悲伤
    2020-12-18 19:56

    This can be achieved by the following way as well:

    .html

    
        
    
    

    .ts

    activatedComponentReference:any
    
    onActivate(activatedComponentReference) {
      this.activatedComponentReference = activatedComponentReference;
    }
    
    onBtnClick() {
       const childRouteComp = this.activatedComponentReference as ChildRouteComponent;
       childRouteComp.childFunction();
    }
    

提交回复
热议问题