Skip to content Skip to sidebar Skip to footer

NodeJS + ExpressJS: Server-side Vs. Client-side Html Rendering

I am new to nodejs and a little confused about the distinction between the server and client side html pages. My goal is to build an e-commerce web store for practice. The stack th

Solution 1:

Q1. Is my logic correct?

My experience says your logic is incorrect. Because there isn't any need for a server side templating engine (in your case, jade) when we are using Angularjs. Angular itself is capable for rendering dynamic data.

What you could do here is use node and express for building API end points for all the functionalities of your shopping cart and then write all the views (both frontend and backend) in Angular.

Q2. Assuming I am trying to keep it up as an MVC structure, which parts correspond to M, V, C in this case?

In angular View is the html page with directives and filters applied. So that represents the UI side of the application. Controllers are the brain for the views.

Views get data from controllers to display. And controllers often fetch data from APIs using services or factories. Controller use an object called $scope to pass data into view. In angular world you can consider this $scope object as the view model. it glues both the view and controller.

So in your example,

/public
     /javascripts
         /item
          ..item.html // view
          ..item.js   // controller (might include the services for item api calls or write a seperate js file for them)

Post a Comment for "NodeJS + ExpressJS: Server-side Vs. Client-side Html Rendering"