Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it necessary to use JADE when building Angular Apps with Node and Express?

Is it possible to build angularJS apps with plain HTML, ExpressJS on NodeJS ?

like image 516
Chris Yeung Avatar asked Nov 09 '13 17:11

Chris Yeung


People also ask

What is jade used for NodeJS?

Jade is a template engine for node. js and the default rendering engine for the Express web framework. It is a new, simplified language that compiles into HTML and is extremely useful for web developers. Jade is designed primarily for server-side templating in node.

Can we use Angular and NodeJS together?

NodeJS takes part in loading the AngularJS application with all the dependencies, such as CSS files and JS files in the browser. For loading all the assets of Angular and accepting all the API calls from the AngularJS applications, NodeJS is generally used as a web server.

Is NodeJS important for Angular?

You do need Node. js to develop Angular applications. All the tools you will run, while developing it, uses Node. js to run, like npm and the Angular CLI itself.

Is Angular better than node?

Node. js is more preferable when faster and scalable web development is needed. It is usually used for building small-sized projects. Angular is preferred when real-time applications, for example, chat apps, or instant messaging are needed.


1 Answers

No it is not necessary, you can use different templating engines with Node & Express or you can just send pure HTML files.

Jade is just a default templating engine that comes with Express.js, If you want a templating engine that is close to bare html i think dust.js is a good one.

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

You can set up 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 like this

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

or, when I was using ember on the frontend it was so conflicting to write handlebars templates in jade templates, so in my jade template I simply included a pure html file like this.

include '/handlebars/templates.html';
like image 130
iConnor Avatar answered Nov 15 '22 06:11

iConnor