Dynamic MenuItem

UI Components for Angular
Post Reply
PIERO62
Posts: 4
Joined: 06 Sep 2018, 20:22

06 Sep 2018, 20:37

Hello I´m trying to add MenuItem dinamically by loading from a json file:

Like that:

Code: Select all

<--The Json File-->
[
    {
        "label": "NAV.LogOut",
        "icon" : "fas fa-sign-out-alt",
        "command" : "this.logout()"
    }
]

<--The Code-->
    private userItems: MenuItem[];
    this.loadAsset.getJSON('./assets/userMenuItems/userMenuItem.json').subscribe(res => {
      if (res != null) { this.userItems = res; }
    });
The all work perfectly except for command that require a function instead of a string.

So the question is how can I pass dinamically the function "logout()" to the command parameter starting from a json string ?

Thanks for helping.


Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests