Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditionally load the context menu #139

Open
drichard1989 opened this issue Jul 24, 2018 · 2 comments
Open

Conditionally load the context menu #139

drichard1989 opened this issue Jul 24, 2018 · 2 comments

Comments

@drichard1989
Copy link

So, right now, there is an empty text attribute, but would it be possible for an attribute to be added in order to load a context menu at all? We are trying to if a variable if false, not load context-menu at all by using ng-attr, but with no luck. Maybe have context-menu-enabled and let a conditional be put in there to be evaluated and if false, not load it at all? That way we don't have it load and have 'empty ' as the only option that displays. Thanks!

@zamb3zi
Copy link

zamb3zi commented Jul 31, 2018

This used to work (see #11) but now we're getting the 'empty' menu when returning [] or undefined.
I've had to work around this by modifying around lines 610 to only do the $broadcast and renderContextMenu if promisedMenu is truthey.

@bartcorremans
Copy link

For anyone who might come across this in the future: You can use the following hack to ensure that the menu never appears if it only contains the default 'empty' option.

this.$rootScope.$on('context-menu-opened', (event, args) => {
    if (!args.params.options.length) {
        // make sure to pass the event name below to the close-menu-on directive option
        this.$rootScope.$broadcast('close-context-menus');
    }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants