I am using angular 2.0.0 with Typescript and trying to build a dynamic menu system which works based on JSON array the component receives.
var menu = [
{id:"menu1", title: " Menu 1", action: "addUser()"},
{id:"menu2", title: " Menu 2", action: "addPhoto()"},
{id:"menu3", title: " Menu 3", action: "addEmail()"}
]
I would like to know the following
- how to set the click action on the menu dynamically?
- Do I use Renderer with ElementRef or do I use DynamicComponentLoader?
- How do I represent the 'action' click function as part of the JSON array above?
Thanks for the help.