I have a directive which creates dynamic datas.I try to run context menu when right click it should go to controller function to run but i can't run function because it can't find controller function from directive.
My Controller:
myapp.controller("myController", ['$scope',
function ($scope)
{
$scope.test=function(){return $scope.Options = [
['test']
];
}
........
My Directive:
myapp.directive('mydirective', [
'$timeout', function ($timeout) {
return {
restrict: 'E',
template: "<a ng-context-menu='test()'>Click Right</a>",
.................
How can i call the controller function from dynamically created data?
controller
field on your directive tomyController
.controllerFactory
option but there does not seem to be one. If you absolutely must do this, you must inject$controller
into a function on thecontroller
field and return a controller that way. But please, do not do this.