从ionic 2中的子组件调用方法
Calling a method from child component in ionic 2
我想在 ionic 2 的另一个子组件 (CustomPage) 的子组件 (HomePage) 中调用一个方法,而不使用任何服务。
我为两个不同的选项卡使用了两个组件
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:
<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>
我想在 ionic 2 的另一个子组件 (CustomPage) 的子组件 (HomePage) 中调用一个方法,而不使用任何服务。 我为两个不同的选项卡使用了两个组件
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:
<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>