I am trying to create dynamic, nested menus in Angular(9), following this link.
I don't know what is missing, getting below errors.
My code in stackblitz. TIA.
I am trying to create dynamic, nested menus in Angular(9), following this link.
I don't know what is missing, getting below errors.
My code in stackblitz. TIA.
The issue here is that menu.childMenu, which is ViewChild, is not initalized yet at the time of passing it to the matMenuTriggerFor directive.
Simple fix is to tell Angular to initialize it before ngOnInit by using static: true option in @ViewChild decorator:
@ViewChild('childMenu', { static: true }) public childMenu;