contextMenu.js
function renderContextMenu (params) {
          /// <summary>Render context menu recursively.</summary>

          // Destructuring:
          var $scope = params.$scope;
          var event = params.event;
          var options = params.options;
          var modelValue = params.modelValue;
          var level = params.level;
          var customClass = params.customClass;

          // Initialize the container. This will be passed around
          var $ul = initContextMenuContainer(params);
          params.$ul = $ul;

          // Register this level of the context menu
          _contextMenus.push($ul);

          /*
           * This object will contain any promises that we have
           * to wait for before trying to adjust the context menu.
           */
          var $promises = [];
          params.$promises = $promises;

          angular.forEach(options, function (item) {

            if (item === null) {
              appendDivider($ul);
            } else {
              // If displayed is anything other than a function or a boolean
              var displayed = resolveBoolOrFunc(item.displayed, params);

              // Only add the <li> if the item is displayed
              if (displayed) {
                var $li = $('<li>');
                var itemParams = angular.extend({}, params);
                itemParams.item = item;
                itemParams.$li = $li;

                if (typeof item[0] === 'object') {
                  custom.initialize($li, item);
                } else {
                  processItem(itemParams);
                }
                if (resolveBoolOrFunc(item.hasTopDivider, itemParams, false)) {
                  appendDivider($ul);
                }
                $ul.append($li);
                if (resolveBoolOrFunc(item.hasBottomDivider, itemParams, false)) {
                  appendDivider($ul);
                }
              }
            }
          });

          if ($ul.children().length === 0) {
            var $emptyLi = angular.element('<li>');
            setElementDisabled($emptyLi);
            $emptyLi.html('<a>' + _emptyText + '</a>');
            $ul.append($emptyLi);
          }

          $document.find('body').append($ul);

          doAfterAllPromises(params);

          $rootScope.$broadcast(ContextMenuEvents.ContextMenuOpened, {
            context: _clickedElement,
            contextMenu: $ul,
            params: params
          });
        }
function renderContextMenu (params) {
          /// <summary>Render context menu recursively.</summary>

          // Destructuring:
          var $scope = params.$scope;
          var event = params.event;
          var options = params.options;
          var modelValue = params.modelValue;
          var level = params.level;
          var customClass = params.customClass;

          // Initialize the container. This will be passed around
          var $ul = initContextMenuContainer(params);
          params.$ul = $ul;

          // Register this level of the context menu
          _contextMenus.push($ul);

          /*
           * This object will contain any promises that we have
           * to wait for before trying to adjust the context menu.
           */
          var $promises = [];
          params.$promises = $promises;

          angular.forEach(options, function (item) {

            if (item === null) {
              appendDivider($ul);
            } else {
              // If displayed is anything other than a function or a boolean
              var displayed = resolveBoolOrFunc(item.displayed, params);

              // Only add the <li> if the item is displayed
              if (displayed) {
                var $li = $('<li>');
                var itemParams = angular.extend({}, params);
                itemParams.item = item;
                itemParams.$li = $li;

                if (typeof item[0] === 'object') {
                  custom.initialize($li, item);
                } else {
                  processItem(itemParams);
                }
                if (resolveBoolOrFunc(item.hasTopDivider, itemParams, false)) {
                  appendDivider($ul);
                }
                $ul.append($li);
                if (resolveBoolOrFunc(item.hasBottomDivider, itemParams, false)) {
                  appendDivider($ul);
                }
              }
            }
          });

          if ($ul.children().length === 0) {
            var $emptyLi = angular.element('<li>');
            setElementDisabled($emptyLi);
            $emptyLi.html('<a>' + _emptyText + '</a>');
            $ul.append($emptyLi);
          }

          $document.find('body').append($ul);

          doAfterAllPromises(params);

          $rootScope.$broadcast(ContextMenuEvents.ContextMenuOpened, {
            context: _clickedElement,
            contextMenu: $ul,
            params: params
          });
        }
function renderContextMenu ( params ) { /// <summary>Render context menu recursively.</summary> // Destructuring: var $scope = params . $scope ; var event = params . event ; var options = params . options ; var modelValue = params . modelValue ; var level = params . level ; var customClass = params . customClass ; // Initialize the container. This will be passed around var $ul = initContextMenuContainer ( params ) ; params . $ul = $ul ; // Register this level of the context menu _contextMenus . push ( $ul ) ; /*
           * This object will contain any promises that we have
           * to wait for before trying to adjust the context menu.
           */ var $promises = [ ] ; params . $promises = $promises ; angular . forEach ( options , function ( item ) { if ( item === null ) { appendDivider ( $ul ) ; } else { // If displayed is anything other than a function or a boolean var displayed = resolveBoolOrFunc ( item . displayed , params ) ; // Only add the <li> if the item is displayed if ( displayed ) { var $li = $ ( '<li>' ) ; var itemParams = angular . extend ( { } , params ) ; itemParams . item = item ; itemParams . $li = $li ; if ( typeof item [ 0 ] === 'object' ) { custom . initialize ( $li , item ) ; } else { processItem ( itemParams ) ; } if ( resolveBoolOrFunc ( item . hasTopDivider , itemParams , false ) ) { appendDivider ( $ul ) ; } $ul . append ( $li ) ; if ( resolveBoolOrFunc ( item . hasBottomDivider , itemParams , false ) ) { appendDivider ( $ul ) ; } } } } ) ; if ( $ul . children ( ) . length === 0 ) { var $emptyLi = angular . element ( '<li>' ) ; setElementDisabled ( $emptyLi ) ; $emptyLi . html ( '<a>' + _emptyText + '</a>' ) ; $ul . append ( $emptyLi ) ; } $document . find ( 'body' ) . append ( $ul ) ; doAfterAllPromises ( params ) ; $rootScope . $broadcast ( ContextMenuEvents . ContextMenuOpened , { context : _clickedElement , contextMenu : $ul , params : params } ) ; }
Responsible for the actual rendering of the context menu.

The parameters in params are:
- $scope = the scope of this context menu
- event = the event that triggered this context menu
- options = the options for this context menu
- modelValue = the value of the model attached to this context menu
- level = the current context menu level (defauts to 0)
- customClass = the custom class to be used for the context menu
Responsible for the actual rendering of the context menu .