0

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 );
           });
        }
    }
});

1 Answer 1

0

my bad i forget to pass parameter in view. i changed from this

edit-task="edit_task()"

to this in my view

edit-task="edit_task(task)"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.