Hi have a problem in that i have a tabComponent. I pass inject a service and pass the tabs array in the service.
I load the tabControl on application startup and insert the contents of another component. This works a charm already. At this point the instance of the tabComponent is already created.
I then have a ribbon Control. I want to press a button and insert content into the already created tabComponent. But i can't work out how to do this. I have a method called addTab in the tabComponent.
TabComponent
ngAfterViewInit() {
// this.createNewTab('dashboard', 'Dashboard' + this.tempTestCounter, {});
this.createNewTab(this._mainTabService.componentModulePath, this._mainTabService.tabName, {});
}
TabService
@Injectable()
export class MainTabService implements iMainTabService {
tabComponents = {};
usedTabs = {};
hiddenTabs: Array<number>;
currentTabId = "tabContent0";
tabName: string; // #mainTabControl
componentModulePath: string;
viewContainerRef: ViewContainerRef;
constructor() {
this.hiddenTabs = Array<number>();
this.tabName = 'Dashboard';
this.componentModulePath = 'dashboard';
}
}
handleRibbonEvent(args) {
switch(args.target.id) {
case 'Default_new_business':
let factory = this.componentFactory.resolveComponentFactory(TabComponent);
this.viewContainerRef = this.tab.createComponent(factory);
//ref.instance.createNewTab('dashboard','Dashboard', {});
default:
break;
}
}