Here is the basic scheme of my app:
Inside parent component I have another component which makes svg chart and inserts all nodes via innerHTML:
//chart.component.html
<div #container>
<svg:svg [innerHTML]="svg"></svg>
</div>
Svg is made with the data provided by the endpoint. I simply glue pieces of strings together and pass whole string via innerHTML. Some of the elements on the chart need to be able to perform some methods (on click). For example yellow buttons will run (click)="getMoreDataAndDisplay()"
.
//example from chart.component.ts
getMoreDataAndDisplay() {
this.endpointTwoService.getMoreSpecificData().subscribe(response => {
this.dataToDisplay = response.json(); //this need to be passed to data.component
this.displayTheData == true;
});
}
After clicking on the button, basing on parameters from the first endpoint, will provide more data from another endpoint and show them in data component.
//parent.component.html
<app-chart></app-chart>
<app-data *ngIf="displayTheData==false"></app-data>
Unfortunately, stuff added by innerHTML seems to be not processed and inserting it like beyond figure in the node but doesn't work:
//example from chart.component.ts
drawRelationButton() {
//draw rectangle button
let relationButtonBase = '<rect (click)="getMoreDataAndDisplay()" x="20" y="50" rx="2" ry="2" width="10px" height="10px" stroke="#b3b3b3" fill="#ffffff" stroke-width="1"></rect>'
return relationButtonBase;
}
I've found similar problems here and here, but since I'm quite new to Angular, feel a bit lost. How to get these buttons work in this case?
Thanks for the help in advance.