How to view the page source for angular 2 app

≯℡__Kan透↙ 提交于 2019-12-04 02:04:14

问题


I have web app, whenever i am view the page source using browser view page source i am only able to see the index.html contents in page source where as i am able to see the all the html code in inspect element but not in page source. Does any one how to view the page source ??

Below is the server.ts


回答1:


It is only possible with Angular Universal (server side rendering). Every javascript files renders in browser, to see page source you have to setup Angular 2 to render on server side. It's also useful for SEO optimization.

On this site you have guide how to setup it.

For Angular 5 you have to visit this page, for more informations.

For example working on NodeJS visit this page



来源:https://stackoverflow.com/questions/48948082/how-to-view-the-page-source-for-angular-2-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!