我在我的离子应用程序中有一个全球页脚,我这样做的方式就是这样。我在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