Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

ryan champin
ryan champin
16,836 Points

Angular.js Experience Needed!!

So my co-developer and I are having trouble deciding the best course of action. Currently, we are developing a single-page webapp using angular. We currently have a skeleton index file that will be injected with different views based on the nav link that is clicked. This works fine, however, this method loads all img, css and js files at once....but it does NOT LOAD ALL VIEWS ON PAGE LOAD.....were using ngRoute to switch between views and what happens is the view is fetched and loaded on nav click...is this the best way? or should we load the entire site at once and use css transitions only to switch views? This is our debate lol help break the tie!! Im voting for the current way bc it is extremely organized and efficient.

3 Answers

ryan champin
ryan champin
16,836 Points

ajax has nothing to do with switching views though. I know ajax and this is regarding using ngRoute for switching views or to use ngClick to just swap views

Ryan. For a "single page web application", as it is often called, the only way to grab the new information to append / replace the current content is to either have it preloaded in one of the "templates" or though an AJAX call. The AJAX call from angular most often goes out to some sort of RESTful API or an internal site link that serves up a JSON object that will then be used to load new information into the "single page web application".

The reason why Angular is so popular for this is due to it's own sort of ORM system, that allows you to use a lot of pure JavaScript instead of having to monkey around with a lot of Rails / Django templateing code, or in-page PHP combined with a mess of event driven jquery based ajax calls.. all on the same page.\

a small side note, AJAX stands for Asymmetrical JavaScript and XHTML.. XHTML is basically HTML5. XML stands for extensible markup language and is used for things like iPhone GUI programing as you can make up your own tags then program them I.e. extensible. XHTML was supposed to be a hybrid of both, ultimately it never became very extensible and it just got an <audio> and <video> tag and was called HTML5.

Francisco José Martín Soto
Francisco José Martín Soto
8,888 Points

Hello Ryan,

I've not worked with angular.js even I don't know what is this used for. But I think that the web app you are developing can be done using AJAX (which is just Javascript + XML or JSON, I prefer JSON because I am familiarized with it).

AJAX is very simple, and in combination with jQuery you can load and place the content with a few lines of code.