I am developing a multiple selection directive, similar to the isteven directive for AngularJs. What I can't solve is that I want to include callback functions, that can pass parameters, that reach their respective function in the controller. For this, use the "&" operator, but for example, if I want an object to be seen in the console, only "undefined" is displayed.
I leave an example:
Template Html:
<li ng-repeat="data in inputData">
<span ng-click="onItemClick()">{{data.name}}</span>
</li>
JS(directive):
debFrontApp.directive('debSelect', function () {
return {
restrict: "AE",
transclude: true,
templateUrl: function (element, attrs) {
if(!attrs.basePath){
attrs.basePath = "/assets/debfront";
}
return attrs.basePath + "/templates/debselect.html";
},
scope: {
multiSelect: '=',
selectName: '@',
inputData: '=inputData',
outputData: '=outputData',
onItemClick: '&'
}
};
});
JS (controller)
$scope.testfuctionBye = function(data){
console.log(data);
};
This function returns an undefined value. Some help? Thank you!