I need a context-menu directive that can provide information on the clicked element for proper reaction.
Although I experimented with this module, I'm facing an issue in uniquely identifying the clicked element. This is hindering my ability to apply the correct logic:
I am looking for a solution where I can pass specific data into the callback function
Controller:
$scope.items.Data = [{Code:'row1', Name:'Name1'},{Code:'row2', Name:'Name2'}]
$scope.items.Actions = [
{
Code: 'Action1',
Name: 'First action'
},
{
Code: 'Action2',
Name: 'Second action'
}
]
var actionList = [];
for (var i = 0; i < $scope.items.Actions.length; i++) {
actionList.push($scope.items.Actions[i].Name, function ($itemScope,$event) {
console.log('Action executed', $scope.objectId, $itemScope,$event,$itemScope.$index);
// Need access to $scope.items.Actions[i].Code or at least the index of the array
});
}
$scope.contextOptions = actionList;
HTML:
<table>
<thead>
<tr>
<td>Code</td>
<td>Name</td>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in items.Data" context-menu="contextOptions">
<td>{{row.Code}}</td>
<td>{{row.Name}}</td>
</tr>
</tbody>
</table>