Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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.