我在我的離子應用程序中有一個全球頁腳,我這樣做的方式就是這樣。我在ion-nav中添加了選擇器組件,它運行良好。我的頁腳顯示在每一頁中。角2離子2,調用子組件undefined
在app.html
<ion-nav [root]="rootPage" #content swipeBackEnabled="false">
</ion-nav>
<call-footer #CallChild></call-footer>
然而,在一個網頁,我想有頁腳的控制,我可以隱藏或更改裏面的變量。在我的頁腳組件中,我有一個名爲'test'的函數,並且在其中一個頁面('調用')中我正在嘗試這個。
calls.ts
import { Component, OnInit, ViewChild} from '@angular/core';
import { oncallpage } from '../calls/oncall/oncall';
import { callfooter } from '../../components/callfooter/callfooter.component';
@Component({
selector: 'page-calls',
templateUrl: 'calls.html'
})
export class callspage implements OnInit {
@ViewChild('CallChild') child;
constructor() { }
ngAfterViewInit() {
this.child.test(); //error
}
但是我得到「無法讀取屬性‘測試’的未定義」
我不知道是否有語法錯誤或我我錯過了一些想法。我該如何解決這個案子?
你的c alls.html的樣子? – echonax
我編輯過。這是一個calls.html –
我沒有看到calls.html。有一個app.html – echonax