In short I'm trying to pass data set in my directive back to its parent controller. I've seen several nuances of this but somewhere I'm missing something and what I'm doing isn't quite working. I have a directive that receives a call back definition from the parent like so:
<my-directive my-list="myData" update-parent="parentCallback(newData)">
The callback in the parent controller is pretty simple but the incoming data is null:
$scope.parentCallback = function(newData) { /* when it gets here its null */ };
The definition of the directive is like so:
myModule.directive('myDirective', function() {
return {
restrict: 'E',
templateUrl: 'Template.html',
replace: true,
scope: { myData: '=', updateParent: '&' },
controller: function($scope, $element, $attrs) {...}
A selection event in the directive's controller attempts to push data back through the callback like so:
$scope.updateSelection = function() {
/* here the data is good */
$scope.updateParent($scope.currentSelection);
};
The current selection variable is defined in the scope for the directive and set by selection on a drop down list box. What is happening is that in the function above it invokes the parent callback, finds it okay, passes in good data, but then when it hits the parent side the arguments are null. I little new to this but I thought the '&' would provide for me passing data back up to the parent. Any help would be greatly appreciated!