0

After searching for hours in google and stackoverflow, I did not get the answer for good practices for AngularJS.

My Questions Are ::

1) Is it a good practice to manipulate a DOM using JQuery and CSS in AngularJS?

2) When to add $injector and $inject explicitly?

3) Is it good practice to use JQuery's $.ajax() method to call the asynchronously in the controller of a Module?

1
  • 2
    Point 1. Only manipulate inside a directive. Commented Mar 20, 2013 at 8:57

1 Answer 1

2

1) Is it a good practice to manipulate a DOM using JQuery and CSS in AngularJS?

You may be surprised how much Angular can do without jQuery. However, jqLite is certainly a "lite" version of jQuery. If you can't do it "clean" in Angular (e.g., if you find yourself writing parent().parent() instead of closest('.element-wrapper')) then sure, reach for jQuery.

2) When to add $injector and $inject explicitly?

Normal dependency injection is usually sufficient. You could, however, dynamically inject a service using the $injector, if you really need to: AngularJS dynamically inject scope or controller

3) Is it good practice to use JQuery's $.ajax() method to call the asynchronously in the controller of a Module?

Use $http or $resource. They do things $.ajax() doesn't, e.g., they'll initiate an AngularJS digest cycle when results come back from the server. Often, you'll want to put your server interaction code into an Angular service.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a lot Mark! And would you please point me towards good documentation of AngularJS. The documentation at their site is poorly constructed.I want to go through the topics in depth.(I am a newbie to AngularJS)
@Srinivas, well, right now, I really can't point you anywhere else for documentation. I learned (I'm still learning) AngularJS from the docs, watching videos, and by reading SO and trying to answer people's questions (which caused me to do a lot of Internet searching and fiddling).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.