Skip to content

Commit

Permalink
Merge pull request #113 from zoladkow/patch-1
Browse files Browse the repository at this point in the history
feature: support dynamic subitems
  • Loading branch information
josetaira authored Sep 30, 2017
2 parents e921554 + 9e094d2 commit c6e9881
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Every menu option is represented by an Object containing the following propertie
- text - [Function/String] A function that returns the string or the actual string itself
- click - [Function] The function to be called on click of the option
- enabled - [Function/Boolean] A function returning whether the option is enabled or not, or a boolean
- children - [Array] An Array of options that will appear as the submenu of the current option
- children - [Array/Promise] An Array of menu options that will appear as the submenu of the current option, or a Promise resolving to a Function which can provide menu options dynamically

### Legacy implementation (still supported, but will not be updated any longer)
Every menu option has an array with 2-3 indexs. Most items will use the `[String, Function]` format. If you need a dynamic item in your context menu you can also use the `[Function, Function]` format.
Expand Down
4 changes: 4 additions & 0 deletions contextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ angular.module('ui.bootstrap.contextMenu', [])
* Regardless, passing them to `when` makes the implementation singular.
*/
$q.when(nestedMenu).then(function(promisedNestedMenu) {
if (angular.isFunction(promisedNestedMenu)) {
// support for dynamic subitems
promisedNestedMenu = promisedNestedMenu.call($scope, $scope, event, modelValue, text, $li);
}
var nestedParam = {
"$scope" : $scope,
"event" : ev,
Expand Down

0 comments on commit c6e9881

Please sign in to comment.