I have created a component "test" with Ionic 2 CLI, and was wondering how do I add this component dynamically to the #componentContainer HomePage from HomePage.ts.
Here is test component:
import { Component } from '@angular/core';
@Component({
selector: 'test',
templateUrl: 'test.html'
})
export class TestComponent {
text: string;
constructor() {
console.log('Hello TestComponent Component');
this.text = 'Hello World';
}
}
And here is my HomePage:
<ion-content padding>
<div #componentContainer>
</div>
</ion-content>
Here is the HomePage.ts
import { Component, ViewChild, ViewContainerRef, ComponentFactoryResolver} from '@angular/core';
import { NavController } from 'ionic-angular';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController) {
}
ngOnInit() {
}
}
Can't find the answer anywhere...