简体   繁体   English

为什么渲染的Angular 2通用服务器具有角度动态属性?

[英]Why Angular 2 universal server rendered have angular dynamic attribute?

I try to understand the behaviour of universal server side rendering. 我尝试了解通用服务器端渲染的行为。

I look the https://github.com/angular/universal-starter/tree/angular-connect project. 我看https://github.com/angular/universal-starter/tree/angular-connect项目。

My first understanding was that the server side rendered version should be free of all the dynamic html attribute generated by angular and then, angular loads and set its dynamic attribute like it want but transparently for me. 我的第一个理解是,服务器端呈现的版本应没有由angular生成的所有动态html属性,然后按角度加载并按需要设置其动态属性,但对我而言是透明的。

Indeed, I observe that the server side generated index is directly "angular annotated". 确实,我观察到服务器端生成的索引直接被“角度注释”。 For example: 例如:

<app _ngcontent-wwg-34="">

(The attribute name is not a constant). (属性名称不是常数)。

Am I right thinking this attribute is server side generated (by nodejs) ? 我是否正确认为此属性是服务器端生成的(由nodejs生成)?

What is the utility of this attribute? 此属性的用途是什么?

How is it used client side? 客户端如何使用?

My final goal is to use a java back-end (no nodejs) : Will I have to follow some strategy to generate this kind of attribute and keep them in session or something like that? 我的最终目标是使用Java后端(无nodejs):我是否必须遵循某种策略来生成此类属性并将其保留在会话中或类似的东西?

Thanks for reading! 谢谢阅读!

The attribute name is not a constant 属性名称不是常量

I don't know what you mean with that. 我不知道你是什么意思。 Each components gets a different attribute name. 每个组件都有一个不同的属性名称。 They are unique for each component type. 它们对于每种组件类型都是唯一的。 The attribute name should not change for the same component type between reloads. 重新加载之间相同组件类型的属性名称不应更改。

_ngcontent-wwg-34=""

Each component gets such an attribute with unique names added, and for CSS added to components the selectors are rewritten to only match these attributes. 每个组件都具有添加了唯一名称的属性,对于添加到组件的CSS,重写选择器以仅匹配这些属性。 This is used to emulate shadow DOM encapsulation. 这用于模拟影子DOM封装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM