mean.js menu isPublic not working

不打扰是莪最后的温柔 提交于 2019-12-30 05:03:08

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/27093701/mean-js-menu-ispublic-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!