with Angular 14, I'm using an ag grid to display rows of data in my main component page. I select a row, click a button and I want to call an auxiliary component HTML file in a separate directory that contains its own typescript file. I am able to collect the row data as JSON data but I want to insert the auxiliary component HTML into my main page.
Q: How can I bind the auxiliary html component to appear in my main html?
Directory Structure
ClientApp
src
app
MyObject
MyObject-grid-main
MyObject-grid-main.css
MyObject-grid-main.html
MyObject-grid-main.ts
MyObject-grid-auxiliary
MyObject-grid-auxiliary.css
MyObject-grid-auxiliary.html
MyObject-grid-auxiliary.ts
MyObject-grid-main.html
<button (click)="getSelectedRowData()">Get More Info</button>
<ag-grid-angular #agGrid id="ag-grid"></ag-grid/angular>
...
<div>
<!-- Here I want to insert MyObject-grid-auxiliary.html after I bind the JSON data -->
</div>
MyObject-grid-main.ts
@ViewChild('agGrid' grid!: GridApi;
getSelectedRowData()
{
const selectedData = this.grid.getSelectedRows();
const jsonDataString = JSON.stringify(selectedData);
alert(`Selected Data:\n${jsonDataString}`); // display in popup
// Here is where I want to bind the JSON data to the MyObject-grid-auxiliary.html
// and have it appear in the place holder above
}
MyObject-grid-auxiliary.html
<h2 class="title">{{data.title}}</h2>
...
<span>{{data.remarks}}</span>
...
<tr *ngFor="let pos of data.locations">
<td>
<span>{{pos.position.lat}}</span>
</td>
<td>
<span>{{pos.position.long}}</span>
</td>
<td>
<span>{{pos.lastReportedOnDateTime}}</span>
</td>
</tr>