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 ?
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With