angular-tree-component creating a context menu

Viewed 748

I have successfully found how to initialise a context menu on the angular-tree-component

const actionMapping: IActionMapping = {
  mouse: {
    contextMenu: (tree, node, $event) => {
      $event.preventDefault();
      alert(`context menu for ${node.data.name}`);

    }
  },

};

but i can't find any documentation on how to actually build and display a menu. So how would I, for example, display a context menu of 2 items {Action A, Action B) with click events for each item?

thanks ...

1 Answers

So you initialized the context menu by implementing IActionMapping interface. Now you need to add it to options like

 options: ITreeOptions = {
    actionMapping
 };

Then include options in the component's input like

<tree-root [nodes]="nodes" [options]="options"></tree-root>

Refer to the documentation here and an example here

In order to build an actual context menu you can see an example here

Related