AngularJS菜单在MEAN.js中是公开的
AngularJS Menu isPublic in MEAN.js
我正在使用 MEAN 创建一个 Web 应用程序.js并且我在导航菜单上遇到了问题。
有几个问题似乎与我的问题有关,但没有一个答案为我解决它,似乎其中大多数都归因于文档错误。
我正在尝试将菜单项设置为公共,这就是我在core.client.config.js中的做法:
Menus.addMenuItem('topbar', 'About Us', 'about', 'item', '/about', true, null, 1);
指定的所有内容都有效,甚至排序也是如此。但是,公共true
参数不执行任何操作。
目前,我只是在menus.client.service.js中将整个topbar
设置为isPublic,但这并不理想,因为我想控制谁可以看到什么!
this.addMenu('topbar', true);
任何帮助将不胜感激!
问题出在 public/modules/core/services/menus.client.service.js为菜单、每个项和子项调用的 shouldRender 函数不检查 isPublic。所以只需添加:
// A private function for rendering decision
var shouldRender = function(user) {
if(this.isPublic){
return true;
}
...
}
并将最后一行更改为:
//Adding the topbar menu
this.addMenu('topbar', true);
因为否则菜单本身永远不会呈现。
现在你可以像这样调用addMenuItem和addSubMenuItem:
Menus.addMenuItem('topbar', 'Articles', 'articles', 'dropdown', '/articles(/create)?', <true/false>);
Menus.addSubMenuItem('topbar', 'articles', 'List Articles', 'articles');
Menus.addSubMenuItem('topbar', 'articles', 'New Article', 'articles/create');
请注意,如果您不提供 true 或 false,则菜单项将从其父项继承。当我们把菜单设置为公开时,每个孩子都是公开的。一旦我们将菜单项设置为私有,孩子们也是私有的。
如果要更改子菜单可见性,请注意参数的数量。第六个论点必须为真。
Menus.addSubMenuItem('topbar', 'articles', 'List Articles', 'articles');
对 VV 的^^更改
Menus.addSubMenuItem('topbar', 'articles', 'List Articles', 'articles', '/articles', true);
当然,您可以更改函数签名以避免这种情况。只需在menus.client.service中交换menuItemUIRoute和isPublic.js
// Add submenu item object
this.addSubMenuItem = function(menuId, rootMenuItemURL, menuItemTitle, menuItemURL, isPublic, menuItemUIRoute, roles, position) {
// Validate that the menu exists
然后你可以像这样添加子菜单:
Menus.addSubMenuItem('topbar', 'articles', 'List Articles', 'articles', true);
相关文章:
- 将js添加到wordpress中以突出显示css活动菜单
- 尝试创建一个具有z-index的堆叠菜单'使用HTML5/CSS3/JS
- JS在选择下拉菜单打开时创建延迟
- JS下拉菜单没有'不起作用
- JS下拉菜单显示在图像旋转器上
- 使用 d3.js 添加下拉菜单
- MEAN.js菜单是如何工作的
- Pebble.js菜单项渲染速度慢
- 使 Ext js 菜单保持打开状态
- 如何使 JS 菜单在悬停或单击时打开
- JS菜单保持菜单状态
- 选择 JS 菜单在服务器中的行为与在我自己的桌面中的行为不同
- 从inquirer.js菜单运行dractor.js测试
- JS菜单与下拉&滑动主要项目
- Fullpage js菜单不会隐藏在第一页
- 网站的JS菜单动画不起作用
- JS菜单,点击菜单关闭菜单
- 使JS菜单在悬停时显示,而不是在单击时显示
- Skrollr.js菜单没有滚动
- JS菜单和预加载屏幕脚本冲突-你可以延迟脚本的预加载吗?