I'm dynamically loading components into my menu bar using DynamicComponentLoader
.
This is what my component class looks like:
@Component({
selector: 'create-submenu-component',
templateUrl: 'common/create/create.component.html',
styleUrls: ['common/create/create.component.css'],
directives: [CreateAssetComponent]
})
export class CreateSubmenuComponent {
public model: Model;
constructor(private _modelService:ModelService, public http: Http) {
this.model = this._modelService.getModel();
}
}
And the dynamic component creation method:
constructor(public injector:Injector){}
loadCreateSubMenu(){
this.dcl.loadAsRoot(CreateSubmenuComponent, '#Create', this.injector);
}
When I'm trying to load the component that contains the Service I'm getting the following error:
Cannot resolve all parameters for 'CreateSubmenuComponent'(undefined, Http). Make sure that all the parameters are decorated with Inject or have valid type annotations and that 'CreateSubmenuComponent' is decorated with Injectable.
The Service being injected is showing up as undefined. Submenu Components that do not rely on a Service load fine. How do I inject the service into the dynamically created component?