Dynamic items in menu

tbegsr
Posts: 4
Joined: 25 Jul 2016, 18:07
Location: Suisse

05 Jan 2018, 00:03

Hi
I try to create a dynamic menu, but I'm not able.
I've always the same status at the point I start the application
Can you give me more information and create an example please

Thx
Rolf

paulswan
Posts: 94
Joined: 27 Apr 2017, 08:19

05 Jan 2018, 02:21

@tbegsr,
There are already 2 examples you can follow in this topic so I don't see how posting another will help. Basically you need to change the model object that the menu is using or Angular will not detect the change. If you are setting the visible property of a menu item to be a Boolean variable and then changing the value of the variable, then this will not work as the model itself has not changed and therefor will not be detected.

tbegsr
Posts: 4
Joined: 25 Jul 2016, 18:07
Location: Suisse

05 Jan 2018, 12:59

@paulswan
Thank you for response
I've seen your example and try to implement it but I was not able
Can you tell me from which class you execute showHideMenuItems(roleID: number):
Many thanks in advanced

paulswan
Posts: 94
Joined: 27 Apr 2017, 08:19

07 Jan 2018, 23:17

@tbegsr,
I actually created a MenuService class for the showHideMenuItems() function as this allows it to be called from anywhere in the application. I build the menu model object within the MenuService as well. I declare the MenuService as a provider in AppModule and initially call it's methods in the ngOnInit() method of the AppMenuComponent.

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest