Im tying to pass object from directive to controller. function is called in controller form directive but parameter i pass to controller function is undefined. here is my code.
//controller function
$scope.edit_task = function(task) {
console.log(task);// this in undefined
};
// directive
myApp.directive('task', function() {
return {
restrict : "EA",
templateUrl : "/views/directives/task.html",
scope: {
taskList: '=',
task: '=',
editTask: '&'
},
link: function(scope, element, attrs){
element.on("change", function(){
console.log(scope.task) // this ok.
scope.editTask( scope.task );
});
}
}
});