I am building a website using nodejs and express. How to make divisions in a page dynamic? Is Jade used for that? if not how to do it?what is angularjs used for? Please help i searched a lot on google and i couldn't get a clarity in the usage of them.
2 Answers
Jade creates the html used in the browser on the server-side. The browser executes a request to the web-server, the web-server executes Jade, which will generate the html that will be sent to the browser. This server-side content generation has been very common in the last ~20 years, but it has quite some cons when building rich internet application. Mostly this has to do with performance and client state tracking.
AngularJS is a client-side MVC/MVVM like framework to build so called Single Page Applications (SPA), which allows you to have the complete user interface flow, all content generation and state tracking to be done at the client side. It even allows you to build offline applications. From the developer point of view this feels much more like building a desktop application where the client knows the state of the user interface. From the user point of the view the website will respond much smoother and snappier because the UI is all generated locally.
Note: SPA does not mean that you can only have one page in your website. It's a technical term where the browser downloads one page (~/index.html), which contains the complete or partial web application. The user technically never leaves this page, but the content (pages) is dynamically swapped in and out from this placeholder page.
To most common way to provide data to a SPA is via RESTful web services. AngularJS comes with builtin support for REST.
Some developers combine server-side content generation techniques with AngularJS, but there's actually no real need for this.

- 7,906
- 3
- 36
- 37
-
Curious to why you say "Some developers combine server-side content generation techniques with AngularJS, but there's actually no real need for this". One reason I can think of straight away is SEO. I know Google has plans to crawl js pages, but I am pretty certain other search engines have not implemented such functionality. Another major reason is speed and user perceived speed. Getting something out on screen right away should be of utmost importance. – TYRONEMICHAEL Jun 12 '14 at 12:12
-
@TyroneMichael It's not that black & white; Angular won't help much with a xml site map and AFAIK there isn't a crawler that will process SPA's without supplying them [some pre-rendered html](http://www.yearofmoo.com/2012/11/angularjs-and-seo.html). In some cases it might be quicker to serve the client a pre-rendered view, but in general this just add some unnecessary complications to the pipeline. Angular is at its best if you let it cache optimised templates and feed it the (json) data from a REST api. – null Jun 12 '14 at 18:06
-
Ya I agree with you 100%. It can definitely complicate things. If however, you can use jade with Angular you can serve the client pre-rendered html using Node and reuse your templates with angular. That's what initially brought me here. Therefore your server and client can reuse templates which simplifies things greatly. – TYRONEMICHAEL Jun 17 '14 at 13:20
-
For the development of an application using nodejs which is best jade or direct using of html and angular? – Rijo Sep 10 '17 at 18:19
Jade is used as a template engine on both server-side and client-side. Yes, it can update a page dynamically, you just have to compile your jade templates to a javascript functions (using jade -c
or something similar).
Yes, you can use angular.js with it, but I see no real need to use two template engines in your project. Suggesting to just stick with jade, unless you know what are you doing.

- 11,935
- 3
- 30
- 42
-
9I use jade to create angular.js partials. I only need it beacuse html is ugly and verbose. – Ilan Frumer Jan 08 '14 at 10:11