Templarian / ui.bootstrap.contextMenu

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

Get Selected Item #117

Closed RogerMito closed 7 years ago

RogerMito commented 7 years ago

Hello. How do I get the selected element after the click event? I have the $ itemScope variable, however I can not get the attributes of the element that was selected from the context menu. Thank you.

josetaira commented 7 years ago

It's the 5th parameter passed to the onclick handler. See https://github.com/Templarian/ui.bootstrap.contextMenu#callback-parameters

RogerMito commented 7 years ago

Hello Friend. I've already figured it out. The contents of the context menu are obtained through AJAX calls. However, I can not delay rendering, and whenever I select an item, the menu contents refer to the last selected variable. That is, in order for me to get the correct content for the current item, I must double-click that item. How could you get around this problem?

Thank you.

josetaira commented 7 years ago

Hi @RogerMito, in version v1.1 (I'll release this soon), you can now use a Promise as your menuOptions. So you can just do something like:

$scope.generateOptions = function() {
  // something that returns a promise
}

Then in your HTML something like:

<div context-menu="generateOptions()" />

You can opt to point your build to the latest commit to test this out.