Home:ALL Converter>angular ajax routing with express

angular ajax routing with express

Ask Time:2015-02-18T12:07:15         Author:Mukhtar Jugger

Json Formatter

My understanding (or misunderstanding): I've just started learning the mean stack and i see that a lot of tutorials (most are pretty old) and some template projects (like mean.io) using angular for routing instead of express (about 80% angular routing and 20% express). My understanding of angular routing is that it is suppose to ajax in a template into the ngView which would keep the page from reloading giving me a true single page application.

my setup: So i have express routing all request to the index file and from there i have created routes in angular for all possible request. each request is routed by angular to a jade template file (which i've seen called partials).

The issue: so i thought that angular would be ajaxing in the partial with each request (giving me the benefit of not having the whole page reload) making a true single page application, but what i've found is that because express (or any other web server for that matter) is routing all request to the index file so angular can do it's thing the index file is always reloaded with each request. because of this, I feel like the ajax routing is meaningless. After all, if the index file is always reloaded on each request which in turn reloads the angular files (and all the js and css files called in the head) then there is no real difference between angular routing and express routing coupled with jade template includes.

The question: Is this the way angular routing coupled with express is meant to be set up and suppose to function or am i doing it all wrong (or when using the mean stack, is it more of a personal choice as to which routing to use rather than a distinct advantage/dis-advantage)?

Author:Mukhtar Jugger,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/28575797/angular-ajax-routing-with-express
yy