在您的gedContextMenu.js
文件中,进行以下更改
注入pluginApp
angular.module('gedContextMenuApp', ['ui.bootstrap', 'mgcrea.ngStrap.popover','pluginApp']);
customSvc
在您的gedContextMenu
菜单指令中注入服务,
angular.module('gedContextMenuApp').directive('gedContextMenu',['$log','$templateCache', '$uibModal', 'customSvc', function($log, $templateCache, $uibModal, customSvc) {
return {
restrict: 'AE',
scope: {
gedContextData: '='
},
template: "<button class='fa fa-cog' bs-popover data-template='{{popoverTemplate}}' data-auto-close='1' data-placement='bottom' data-animation='am-flip-x'></button>",
controller: function($scope) {
$scope.popoverTemplate = 'popoverTemplate.html';
$scope.executePlugin = function($event, contextItem) {
var propName = contextItem.action;
$scope.contextItem = contextItem;
$log.info('property name ' + propName + ' used to trigger event ', $event.type);
$scope[propName] = $event;
}
$scope.click = function($event, contextItem) {
$scope.executePlugin($event, contextItem);
}
},
link: function(scope, element, attrs) {
scope.$watch('openDialog', function(event) {
if (event && event.type === 'click') {
console.log(customSvc);
// var customSvc = angular.injector(['ng', 'pluginApp']).get("customSvc");
//angular.injector(['ng', function($provide) {
// var $rootElement = angular.element(document.querySelector('body'));
// $provide.value('$rootElement', $rootElement);
//}]).invoke(function($injector) {
// var localRootElement = $injector.get('$rootElement');
//});
// customSvc.testOpenDialog(100, scope);
//customSvc.testDirettivaConfirm(100, scope);
}
});
}
}
}]);