Templarian / ui.bootstrap.contextMenu

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

clickFunction always null #150

Closed tgibson1 closed 4 years ago

tgibson1 commented 4 years ago

var clickFunction = angular.isFunction(item.click) ? item.click : (angular.isFunction(item[1]) ? item[1] : null);

                            if (clickFunction) {
                                var res = clickFunction.call($scope, $scope, event, modelValue, text, $li);
                                if (res === undefined || res) {
                                    cleanupFunction();
                                }
                            } else {
                                cleanupFunction();
                            }

The click handler is always null eventhough I am assigning a function to it in the controller (controller below)

$scope.menuOptions = [ // NEW IMPLEMENTATION { text: 'Object-Select', click: function ($itemScope, $event, modelValue, text, $li) { alert("Contact Service Provider"); $scope.selected = $itemScope.item.name; } }, { text: 'Object-Remove', click: function ($itemScope, $event, modelValue, text, $li) { alert("Contact Service Provider"); $scope.items.splice($itemScope.$index, 1); } }, // LEGACY IMPLEMENTATION ['Select', function ($itemScope, $event, modelValue, text, $li) { alert("Contact Service Provider"); $scope.selected = $itemScope.item.name; }], null, // Dividier ['Remove', function ($itemScope, $event, modelValue, text, $li) { alert("Contact Service Provider"); $scope.items.splice($itemScope.$index, 1); }] ];

tgibson1 commented 4 years ago

issue was due to passing menu options using interpolation

wrong way: context-menu={{menuOptions}} correct way:context-menu=menuOptions