Templarian / ui.bootstrap.contextMenu

AngularJS Bootstrap UI Context Menu
MIT License
259 stars 127 forks source link

Feature: Allow for late loading of nested menu options #37

Closed josetaira closed 8 years ago

josetaira commented 8 years ago

Have a parameter you can specify that will be called to return the array that will be supplied to the nested menu before it is rendered. I'm thinking this can be simple function that returns the nested menu array which will be called before render menu of the nested arrays, or it can be an object, something like: {"nestedMenuLoader": function(){return []};}.

The object option might be better since from here any future new parameters can just be a new key in this object. Your thoughts?

Templarian commented 8 years ago

Probably easier to make context-menu="menuOptions" allow...

$scope.menuOptions = function (name) {
    var deferred = $q.defer();
    setTimeout(function() {
        deferred.resolve([
            // resolved menu items.
        ]);
    }, 1000);
    return deferred.promise;
}

It already allows a function that returns an array so returning a promise would be easier to understand.

josetaira commented 8 years ago

@Templarian yeah, seems logical. Any plans on implementing this any time soon?

josetaira commented 8 years ago

I've implemented this and created a PR here: https://github.com/Templarian/ui.bootstrap.contextMenu/pull/52

My implementation is a bit different that only nested menus are supported as promises. The main menu must be your default menu structure.