1

I-m trying to create a custom directive, and bind it a specific div, however, I only can bind it to input, any way to bind it for divs?

link : function(scope, element, attrs) { 

     element.bind('input', function(e) {}); // works perfectly
     element.bind('#myDiv', function(e) {}); //does not work!

}
1
  • yes and yes, any other requirement? Commented Nov 12, 2015 at 14:06

1 Answer 1

1

Basically .bind methods needs, the element on which you want to bind an event should be there on left on side

angular.element('#myDiv').bind('click', function(e) {});

Basically .bind method takes an eventType, eventData & eventHandler

.bind( eventType [, eventData ], handler )

The code which you are saying working perfectly should not work.

Sign up to request clarification or add additional context in comments.

1 Comment

what exactly is this eventData?

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.