|
[app.component.html]
<ng-template #CustomTemplate>
<div style="height:80%; width: 100%;" class="templateContent">
<splinechart-root style="height:80%;
width: 100%;"></splinechart-root>
</div>
</ng-template>
<!--
adding a ng container to append the template in the container -->
<ng-container #viewContainer></ng-container>
[app.component.ts]
onAdd():
void {
this.count
= this.count
+ 1;
let
panel: any = [
{
id: this.count.toString(),
sizeX: 2,
sizeY: 2,
row: 0,
col: 0,
type: 'readyToSetTemplate',
},
];
this.dashboardObject.addPanel(panel[0]);
switch
(panel[0].type) {
case 'readyToSetTemplate':
this.splineT();
break;
}
}
splineT()
{
const templateValue = this.CustomTemplate.createEmbeddedView(null);
// inserts the template into the view container
this.viewContainer.insert(templateValue);
// Obtaining the content element of the panel
let
panel_Content = document.getElementById(
this.count.toString() + '_content'
);
// appending the template to the panel content element.
panel_Content.appendChild(templateValue.rootNodes[0]);
}
|