0

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 menuOptionsdeclared 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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.