从ionic 2的子组件中调用方法

时间:2018-12-17 10:50:16

标签: angular ionic2

我想从离子2的另一个子组件(CustomPage)中的子组件(HomePage)调用方法,而无需使用任何服务。 我正在为两个不同的标签使用两个组件

1 个答案:

答案 0 :(得分:0)

You can use a template variable to get a reference to the sibling. If <app-controls> has an output where it emits events when a button is clicked you can do:

check this

<app-controls (buttonClicked)="main.doSomething($event)"></app-controls>
<app-main #main></app-main>
or you can pass a reference to a @Input() siblings; and then call methods on it:

<app-controls [sibling]="main"></app-controls>
<app-main #main></app-main>