Heeey everyone!
I’m testing a component from: https://www.joshmorony.com/how-to-create-a-sliding-drawer-component-for-ionic-2/
I want to apply it to my configuration, that’s why I have to use @ViewChild.
This is my parent file:
import { Component, Input, ElementRef, Renderer, ViewChild } from '@angular/core';
import { Platform, DomController } from 'ionic-angular';
import { HomePage } from '../../pages/home/home';
@Component({
selector: 'content-drawer',
templateUrl: 'content-drawer.html'
})
export class ContentDrawer {
@Input('options') options: any;
@ViewChild('HomePage') homePage: HomePage;
handleHeight: number = 50;
bounceBack: boolean = true;
thresholdTop: number = 200;
thresholdBottom: number = 200;
constructor(public element: ElementRef, public renderer: Renderer, public domCtrl: DomController, public platform: Platform) {
}
ngAfterViewInit() {
console.log(this.homePage.stateFilter);
..........
}
}
and my child file:
import { Component } from '@angular/core';
....
import { Http } from '@angular/http';
@IonicPage({
name: 'HomePage'
})
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
......
stateFilter: any = 'noFilterModal';
statePoi: any = 'noPoiModal';
......
}
…but I got this error:
Error: Uncaught (in promise): TypeError: Cannot read property 'stateFilter' of undefined
…and I dont understand because I’m using ViewChild