I'm encountering a problem where if I dynamically load a component, none of the bindings in the template are working for me. As well as this the ngOnInit method is never triggered.
loadView() {
this._dcl.loadAsRoot(Injected, null, this._injector).then(component => {
console.info('Component loaded');
})
}
Dynamically loaded component
import {Component, ElementRef, OnInit} from 'angular2/core'
declare var $:any
@Component({
selector: 'tester',
template: `
<h1>Dynamically loaded component</h1>
<span>{{title}}</span>
`
})
export class Injected implements OnInit {
public title:string = "Some text"
constructor(){}
ngOnInit() {
console.info('Injected onInit');
}
}
This is my first time using dynamically loaded components so I think may be attempting to implement it incorrectly.
Here's a plunkr demonstrating the issue. Any help would be appreciated.
loadAsRoot. Your safest bet for now is to use eitherloadNextToLocationorloadIntoLocation.fixedcss style, so the dialog needs to be loaded pretty much as a first child of thebodytag. Can I do this withloadNextToLocationorloadIntoLocationfrom within a deeply nested component?AppComponentwith forward ref and am now usingloadIntoLocationwith theAppComponent'sElementRef. Thanks for your help.