I have a JSON file from which I get configuration to generate an array of buttons in a toolbar.
In each record, I store information about each button, as well as the class, the icon ... and I also want to set in each button the method that will trigger through the event (click)
How do I generate each button in the view with its click event?
It is an angular component that generates a toolbar based on the information it receives from this JSON file
I need something like:
HTML
<mat-button-toggle-group>
<mat-button-toggle *ngFor="let tool of tools">
<button [click]="tool.click"><i [class]="tool.class"></i></button>
</mat-button-toggle>
</mat-button-toggle-group>
Array (JSON file)
tools =
[
{ id: 0, class: 'fas fa-sign-out-alt', click: 'addPizza()'},
{ id: 1, class: 'fas fa-arrow-left', click: 'removePizza()' },
{ id: 2, class: 'far fa-sticky-note', click: 'updateGrid()' }
];
Expected: Generate a group of buttons within each button has a specific method