I am trying to pass a variable from a page to my custom child component and log as 'undefined'. I want this value in child component so that I can call another service onloading child component. please help.
child.component.ts
import { Component, Input , OnInit} from '@angular/core';
import { IonicPage, NavController, NavParams, AlertController } from 'ionic-angular';
@Component({
selector: 'well-subsurface',
templateUrl: 'well-subsurface.html'
})
export class WellSubsurfaceComponent {
@Input() data;
wID: string;
constructor(
public navParams: NavParams) {
}
async ngOnInit() {
this.wID = this.data;
console.log("------ "+ this.wID)
}
}
parent.component.ts
import { Component, ViewChild } from '@angular/core';
import { IonicPage, NavController, NavParams, AlertController } from 'ionic-angular';
@IonicPage()
@Component({
selector: 'page-asset',
templateUrl: 'asset.html',
})
export class AssetPage {
public wID: any;
constructor(public navCtrl: NavController,
public navParams: NavParams,
public alertCtrl: AlertController
) {
}
MenuContorl(assetID) {
this.wID = wID;
}
}
parent.html
<well-subsurface></well-subsurface>