Angular 2 - How to trigger a method on a child from the parent

前端 未结 2 1197
清酒与你
清酒与你 2020-12-24 10:50

It\'s possible to send data from the parent to a child through @Input, or to call a method on the parent from the child with @Output, but I\'d like to do exactly the other w

2条回答
  •  既然无缘
    2020-12-24 11:07

    I think these might be what you're looking for:

    https://angular.io/guide/component-interaction#parent-interacts-with-child-via-local-variable

    https://angular.io/guide/component-interaction#parent-calls-an-viewchild

    You can access child properties and methods using local variables within the template or using the @ViewChild decorator in the parent's component class.

提交回复
热议问题