如何查看 angular 2 应用程序的页面源代码 [英] How to view the page source for angular 2 app

查看:31
本文介绍了如何查看 angular 2 应用程序的页面源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有网络应用程序,每当我使用浏览器视图页面源查看页面源时,我只能看到页面源中的 index.html 内容,因为我能够看到检查元素中的所有 html 代码,但是不在页面源中.有没有人怎么查看网页源码??

下面是 server.ts

解决方案

只有 Angular Universal 才有可能(服务器端渲染).每个 javascript 文件都在浏览器中呈现,要查看页面源,您必须设置 Angular 2 以在服务器端呈现.它也可用于 SEO 优化.

这个网站上,您可以指导如何设置.

对于 Angular 5,您必须访问此页面,了解更多信息信息.

例如在 NodeJS 上工作,请访问此页面

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

解决方案

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

这篇关于如何查看 angular 2 应用程序的页面源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆