Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

'This' conflicts in angular and Jquery

I am trying to migrate a angularjs application into angular. The old application had jquery functionalites. I tried using the same. Issue with ‘this’ element.

When loading in angular, angular takes ‘this’ element has its component one and jquery ‘this’ element doesnt show up.

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Appreciate any help!!!

>Solution :

Just replace your arrow function in click by function.

using this inside arrow functions body will not create a new lexical context , hence your result.

Inside jQuery methods, such as click you need to use functions expressions that will allow the lexical context this to be bound to the current dom element.

Important reading about this, http://perfectionkills.com/know-thy-reference, spec about arrow functions and their pitfalls can be useful too.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading