Reputation: 179
I am using this angularJS contextMenu module on my application and I need to insert this inside some HTML tags dynamically. I am trying something like this but it isn't working.
e.client.html("<a context-menu=\"menuOptions\">click here</a>");
I have menuOptions
declared on my scope like this:
$scope.menuOptions = [
{
text: 'Object-Select',
click: function ($itemScope, $event, modelValue, text, $li) {
$scope.selected = $itemScope.item.name;
}
},
{
text: 'Object-Remove',
click: function ($itemScope, $event, modelValue, text, $li) {
$scope.items.splice($itemScope.$index, 1);
}
}
];
Someone know how to do that?
Upvotes: 0
Views: 389
Reputation: 3153
You need angular to compile your dynamic context menu, so it can handle the context-menu
directive. The best way doing this is:
//define the Html to insert in a variable:
var dynContextMenu = "<a context-menu=\"menuOptions\">click here</a>";
//append to content
e.client.html(dynContextMenu);
//then compile it
$compile(dynContextMenu)($scope);
I hope this helps.
Upvotes: 1