Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using jQuery in combination with AngularJS?

I'm working to develop a single page framework for my company. We build lots of sites and we build them quickly so we still rely heavily on multi-page, server side templates. This means front-end developers pretty much only have to deal with CSS and jQuery for some basic DOM manipulation. It's a great system for what we currently do, but moving into the future of JS based single page sites, it requires lots time for new project resources (especially front-end developers) to get up to speed.

Currently, all of our single-page applications rely on jQuery and jQote2 for simple page transitions (like the entire container is simply replaced). Again, this works great since many of our sites are simple and straight forward, but it becomes a mess when we need to do anything custom and it can sometimes take developers hours to figure out how to make a simple change.

I've been looking into using Angular simply to manage "pages" and handle displaying the correct template based on a server call. Once Angular has displayed the page the correct template and page, I want the front-end dev's to be able to use jQuery to manipulate the current page similar to how one would manipulate a multi-page site.

For me the big bonus with Angular (compared to jQuery or jQM) is the in element directives. It's just so clear and easy for a developer to fire the site up, take a quick look at the DOM and understand how it's being modified.

Essentially, I want Angular to serve as the controller (and model when necessary), then plop a view down for jQuery to interact with. Is it possible to use Angular with jQuery in such a manner?

Is Angular total overkill for such a simple task? (I know I can write something custom, but Angular just seems to kick butt and has the ability to easily expand to our larger sites)

like image 914
wharding28 Avatar asked Jul 17 '13 06:07

wharding28


People also ask

Can we use jQuery and AngularJS together?

Yes, AngularJS can use jQuery if it's present in your app when the application is being bootstrapped. If jQuery is not present in your script path, AngularJS falls back to its own implementation of the subset of jQuery that we call jQLite.

Why jQuery is not used in Angular?

in fact you should include it before the angular scripts, so angular will use jQuery instead of its jqlite (jQuery subset). the main disadvantage of adding jQuery is the size of the library. the angular team recommends you avoid use jqlite or jQuery in angular controllers, you should use angular directives instead.

Can we use jQuery plugin in Angular?

Most beginners prefer to write an Angular wrapper for the jQuery plugin. In this, all we have to do is apply an Angular Attribute Directive appToolbarBoys on the toolbarBtn button and instantiate the jQuery plugin when the directive is initialized.


1 Answers

It is not an overkill to use angularjs, as it is a great framework for the possibility of expanding the project. MVC structure also makes it powerful. For angularjs and jquery relation, see this, this, this

like image 154
Yagiz Ozturk Avatar answered Sep 28 '22 07:09

Yagiz Ozturk