I have created a child component called 'SideMenuComponent'. It dynamically creates menu buttons according to "items" input.
export class SideMenuComponent {
@Input() items: IMenuNode[];
...
template
<div *ngFor="let item of items">
<button (click)="item.click(item)">{{item.text}}</button>
</div>
And in the parent component, i created a menu array.
export class ParentComponent {
public items: IMenuNode[] = [
{
text: "Help",
icon: "help",
click: () => { console.log("help me")}
},
{
text: "Feedback",
icon: "feedback",
}
];
...
and used it in the template.
<sidemenucomponent-selector [items]="items"></sidemenucomponent-selector>
Buttons and their icons are displayed without a problem. However, click function does not work. When I click Help it does not print "help me"
click: () => { console.log("help")}
How can I fix it?