I'm working on passing a resource from a directive scope to a controller scope by utilizing a callback provided in the view. However, I'm encountering an issue where the argument variable is showing as undefined
. Can you help me figure out what I'm missing?
For reference, here's a jsfiddle example of the issue: https://jsfiddle.net/xqknpe5d/
View
<div on-my-event="doStuff(foo)"></div>
Directive
App.directive('myDirective', ['$whateverModule', function($module) {
return {
restrict: 'A',
scope: {
onMyEvent: '&'
},
link: function(scope, element, attrs) {
(scope.onMyEvent) && ( scope.onMyEvent('moo') );
}
};
}]);
Controller
ctrls.controller('myController', ['$scope', function($scope) {
$scope.doStuff = function(foo) {
console.log('moo: ', foo);
};
}]);
Any assistance would be greatly appreciated. Thank you.