Page 1 of 1

hide menu item in 2.0

Posted: 31 Jan 2017, 07:29
by mthor1979
now that the menu is done on the .ts page with a array this.model = [{label:dashboard, icon: 'dashboard', routerLink: ['/']}]

how do we hide a menu item , I have many use cases where I need to hide/show menu items, not sure how to do with the latest release

thanks

Re: hide menu item in 2.0

Posted: 31 Jan 2017, 08:30
by DarthMaul
Hi,

Can you explain it more spesific afterwards i will try to replicate and achieve it.

Re: hide menu item in 2.0

Posted: 31 Jan 2017, 15:50
by mthor1979
I will try to explain a little more. in the left side menu, (dashboard, customize, theme) I have other menu names ex.) password, pin, voicemail, speeddials...

some of my users can not see the menu link voicemail, cause they do not have access to our voicemail system. so when this user logs into our application we return a flag (voicemailEnabled: false). When I see this value as false, I need to hide the menu item link voicemail. usually I have them hidden by default and then show the menu item if voicemailEnabled === true.

does that help explain a little better?


The way I can come up with is to create my menu array based on the data then push those menu items to the model array. is there a better solution?


thanks

Re: hide menu item in 2.0

Posted: 31 Jan 2017, 15:57
by DarthMaul
Maybe you can try using *ngIf = voicemailEnabled for deleting it from dom.

Re: hide menu item in 2.0

Posted: 31 Jan 2017, 17:54
by cagatay.civici
How about removing it from your model so that it will be removed from dom as well.

Another approach would be;

https://github.com/primefaces/primeng/issues/1959

Where we'll bind the visible property to ngIf in menu of Ultima.

Re: hide menu item in 2.0

Posted: 31 Jan 2017, 19:13
by mthor1979
good options, thanks

Re: hide menu item in 2.0

Posted: 03 Oct 2019, 08:49
by mohammed ameen534
Hi did you get any solution ?? please let me know .. my situation is also same like @mthor .i need to hide/show the label from menu item based on condition