Do I need to use JADE when creating Angular applications using Node and Express?

Is it possible to create angularJS applications with simple HTML, ExpressJS on NodeJS?

+6
source share
3 answers

No , this is not necessary, you can use different template engines with Node and Express, or you can just send clean HTML files.

Jade is just the default template engine that comes with Express.js. If you want the template engine to be close to the bare html, I think dust.js is good.

Quite frankly angular.js has nothing to do with it.

You can configure express to render pure html files like this.

app.configure(function(){ app.set("view options", { layout: false }); app.register('.html', { compile: function(string, options){ return function(locals){ return string; }; } }); }); 

Then just render

 app.get('/myUrl', function(request, response){ response.render("index.html"); }); 

or when I used ember on the interface, it was so difficult to write handlebars templates in jade templates, so in my jade template I just included a clean html file like this.

 include '/handlebars/templates.html'; 
+9
source

Yes it is possible. Jade is (first of all - and I imagine how you use it) the server-side template engine. Angular is based on HTML served by the client; it doesnโ€™t matter what produced it. NodeJS is just a server. Express is only a server infrastructure.

Angular can work even without a server; see jsFiddle for example.

+1
source

EJS is another structure that is popular in Express and is pretty close to plain HTML.

0
source

Source: https://habr.com/ru/post/957747/


All Articles