How to call router outlet child component method from parent comonent

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

I am new to angular2


    

I have a button in parent component, if

10条回答
  •  时光说笑
    2020-12-18 20:11

    Although it is an old questions, all the replies here are not perfect.

    By using either service or child instance, you bind yourself to a specific function name that you need to call. service also forces you to use dependency injection.

    There is a better way, by using a directive which makes each side completely independent from the other.

    the directive is ng-router-outlet-comm.

提交回复
热议问题