rajvishal777
rajvishal777

Reputation: 15

Server side Rendering HTML template

I have an Angular 1 web-app deployed in which all views(html) are at client side. I have REST APIs exposed at server end which my Angular services uses to get JSON response and then I populate this in my view and render it to UI. Now I plan to render view at sever end.

I can't change my tech stack at client end but I do have freedom of stack at server end.

Blogs are suggesting to use REACT for server side rendering but I am doubtful if we can have server side rendering in REACT and client in Angular. What other alternatives do I have ??

Please do suggest any possible alternatives. Thanks in advance

Upvotes: 1

Views: 968

Answers (1)

Jorge
Jorge

Reputation: 560

If you were using Angular2 you can get an isomorphic solution like https://github.com/angular/universal

The approach I can see here, and that I have discuss with mates in the past is to "double" the routes on your API. Then you should have a route in which you render an HTML template with, for example, jade and send it to the client. Then, using AngularJS you manipulate the dom as usually and subsequent route changes could be handled by AngularJS router.

So the "algorithm" should be:

  1. Ask for URL
  2. API handles route and generate a compiled view and sends it
  3. Now AngularJS handles the routes with its router and the DOM manipulation
  4. Subsequent requests to other views needs to repeat same process.

Hope it helps!

Upvotes: 0

Related Questions