Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mean.js menu isPublic not working

In a mean.js app, I wanted to display the menu items in the top navbar while the user is signed in as well as signed out. The menu items are displaying while the user is signed in, however, that is not happening when the user is signed out.

The mean.js docs state setting the 'isPublic' property to true will allow for the menu items to be shown on the navbar while user is signed out; but that is not working. Here is the code:

Menus.addMenuItem('topbar', 'Talks', 'talks', 'dropdown', '/talks(/create)?', true); Menus.addSubMenuItem('topbar', 'talks', 'List Talks', 'talks'); Menus.addSubMenuItem('topbar', 'talks', 'New Talk', 'talks/create');

The solutions I looked at, all suggest to set the isPublic property to true, but there seems to be too much confusion around this subject. Anyone with answers?

like image 476
user3681587 Avatar asked Nov 23 '14 20:11

user3681587


1 Answers

If you look in menus.client.services.js in the core module of mean.js the last line looks like this: this.addMenu('topbar');. If you change it to this.addMenu('topbar', true);. You will see all your menu items showing on the topbar when you aren't logged in. Then you can add your menu item like in your example or without the true as it will inherit it from the setting that was just changed:

Menus.addMenuItem('topbar', 'Talks', 'talks', 'dropdown', '/talks(/create)?');
OR
Menus.addMenuItem('topbar', 'Talks', 'talks', 'dropdown', '/talks(/create)?', true);

Or like below if you now want it to hide when not signed in:

Menus.addMenuItem('topbar', 'Talks', 'talks', 'dropdown', '/talks(/create)?', false); 

I hope this helps.

like image 139
Marc Harry Avatar answered Nov 14 '22 23:11

Marc Harry