Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it good to use a jquery library inside an angular 6 Project?

Tags:

angular

I am creating an angular 6 Project which was earlier developed using jquery and now I am stucked as if it is good to use jquery inside Angular 6 or I should remove all the jquery codes and replace it with Angular ?

like image 457
Pawan lakhera Avatar asked Jul 30 '18 09:07

Pawan lakhera


People also ask

Can we use jQuery in Angular 6?

In the above code, we first import jquery to use its component. We then need to implement ngOnInit Lifecycle Hook which can be imported from Angular Core. We can write jQuery code inside the method ngOnInit, To add the action to the button we created in app. component.

Can I use jQuery inside Angular?

jQuery is a small yet feature-rich powerful javascript library that helps to manipulate the HTML DOM with less javascript code. We can use jQuery with Angular. There are some situations you come across while building Angular apps that it's absolutely necessary to use a library like jQuery to get something done.

Is it a good or bad practice to use Angularjs together with jQuery?

We have recently found out that the development team has build this functionality by using jQuery instead of Angular. From what I have researched so far, using jQuery in an Angular platform is bad practice and can make the platform more complicated for management and updates.

Does TypeScript use jQuery?

JQuery is one of the most popular JavaScript libraries which exposes a lot of usable APIs for JavaScript developers. It's an integration with Typescript that may do wonders for you.


1 Answers

No, it is not a good idea. You are using jQuery coding practices in an Angular app and this will cause you headaches - for once because those practices go against the Angular spirit, and also because you don't reap the benefits of Angular.

You can do everything you do with jquery with angular like DOM changes , listen to event component event or windows event , create dynamic html elemnt and angular will track all these kind of change and your app doesn't have any side effect for example select elment value changes and angular haven't got this kind of changes.

you may thenk using jquery because you already have an experience or want to get the benefit of jquery plugins , currently there are alot of ui package realted to angular and some company develop a complete ui component like primeng,kendo ui

angular is a structure of how to build a web app so if you want to get the benefit of the app performance ,well done architecture base on the best practice of building web app, and app smallest size you have to stick to angular things like components and ui package.

like image 92
Muhammed Albarmavi Avatar answered Oct 20 '22 00:10

Muhammed Albarmavi