runtimeZero
runtimeZero

Reputation: 28046

What's the difference between element.bind and element.on

Folks,

I have been following examples of angularjs directives. I see some people use:

element.bind('click',callback)

while others use:

element.on('click',callback)

Any clue on what is the difference between the two and which should be applied when ?

Upvotes: 34

Views: 21003

Answers (1)

Fresheyeball
Fresheyeball

Reputation: 30015

There is no functional difference. jQuery officially deprecated all binding syntaxes other than .on. Because jqlite angular.element is based on jQuery, they moved the syntax to .on inorder to be more compliant for those who use jQuery and Angular together. jqlite still allows for .bind to be backwards compatible (as does jQuery).

You can learn more about the differences here : jquery .bind() vs. .on()

Upvotes: 36

Related Questions