[英]Server side Rendering HTML template
I have an Angular 1 web-app deployed in which all views(html) are at client side. 我部署了一个Angular 1 Web应用程序,其中所有视图(html)都在客户端。 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. 我在服务器端暴露了REST API,我的Angular服务使用它来获取JSON响应,然后在我的视图中填充它并将其呈现给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. 博客建议使用REACT进行服务器端渲染,但我怀疑是否可以在REACT和Angular中的客户端进行服务器端渲染。 What other alternatives do I have ?? 我还有其他什么选择?
Please do suggest any possible alternatives. 请建议任何可能的替代方案。 Thanks in advance 提前致谢
If you were using Angular2 you can get an isomorphic solution like https://github.com/angular/universal
如果您使用的是Angular2,您可以获得一个同构解决方案,如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. 我在这里看到的方法,以及我过去与配偶讨论的方法是“加倍”API上的路由。 Then you should have a route in which you render an HTML template with, for example, jade and send it to the client. 然后你应该有一个路由,你用它来渲染一个HTML模板,例如,jade并将其发送到客户端。 Then, using AngularJS you manipulate the dom as usually and subsequent route changes could be handled by AngularJS router. 然后,使用AngularJS,您通常会操纵dom,AngularJS路由器可以处理后续路由更改。
So the "algorithm" should be: 所以“算法”应该是:
Hope it helps! 希望能帮助到你!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.