I am using the exact implementation of angular 2's dynamic component loader as described here: https://angular.io/docs/ts/latest/api/core/DynamicComponentLoader-class.html (specifically the loadAsRoot implementation).
It works fine. However, now I want to extend this in the following way: The parent has certain width x height, which I pass to a service. Then, in the child I subscribe to the service, and render the child dimensions with ngStyle.
This works fine throughout the app, except when I use dynamic component loader! It is not an issue with the service, it fires the width and height to the console correctly upon instantiation of the component. But whatever I put in ngStyle does not get rendered.
What am I doing wrong, and what are my options to work my way around this?
Thank you.
Edit:
Example code:
@Component({
selector: 'child-component',
template: '<div [ngStyle]="{'background-color':'red'}">Child</div>'
})
class ChildComponent {
}
@Component({
selector: 'my-app',
template: 'Parent (<child id="child"></child>)'
})
class MyApp {
constructor(dcl: DynamicComponentLoader, injector: Injector) {
dcl.loadAsRoot(ChildComponent, '#child', injector);
}
}
bootstrap(MyApp);
The invocation of ngStyle has no effect.