Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

angularjs

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 ?

like image 436
runtimeZero Avatar asked Feb 20 '14 16:02

runtimeZero


1 Answers

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()

like image 87
Fresheyeball Avatar answered Oct 19 '22 03:10

Fresheyeball