I am using DynamicComponentLoader as described here in the angular2 API manual,
https://angular.io/docs/ts/latest/api/core/DynamicComponentLoader-class.html
I set my code so that it looks like this:
import {Page} from 'ionic-framework/ionic'; import { Component, View, DynamicComponentLoader, Injector } from 'angular2/core'; import { RouteParams } from 'angular2/router'; import { DataService } from '../../services/dataService'; import { Section } from '../../models/section'; @Component ({ selector : 'itemView', template : '<div id="content"></div>' }) export class ItemView { constructor (private dataService : DataService, private _routeParams : RouteParams, dcl: DynamicComponentLoader, injector: Injector) { var sectionid = this._routeParams.get ('sectionid'); var categoryid = this._routeParams.get ('categoryid'); var itemid = this._routeParams.get ('itemid'); var views = {product: ItemproductView, dispensor: ItemdispensorView, signage: ItemsignageView, equipment: ItemequipmentView}; if (categoryid !== null) { this.item = dataService.getCategoryItem (sectionid, categoryid, itemid); } else { this.item = dataService.getItem (sectionid, itemid); } dcl.loadAsRoot(views[sectionid], '#content', injector); } }
I see the template in my web browser, however {{item}} is not linked in the template.
I am not too sure where I am going wrong and any help would be appreciated.
Thanks,
source share