我有一个角度应用程序,在这里我需要一个自定义视觉组件(带有模板)来取消其自定义标签/元素。父应用程序的CSS会在注入新的component元素时丢失。我相信这是一个普遍的抱怨,我发现的最佳建议是使组件具有属性选择器。
这似乎很好用,但是我发现在添加带有属性选择器的组件时,该容器元素内的其他元素被抑制了。看来我做错了什么,还是这是属性选择器的已知限制?
这里显示的是a quick stackblitz。我希望这是一个简单的菜鸟错误?
带有属性选择器的简单组件:
<hello name="{{ name }}"></hello>
<p>
Start editing to see some magic happen :)
</p>
<!--This shows the use of the attribute component. The component shows up, but the other items in the paragraph do not-->
<p appAttrib title="inner text here">
Here is some paragraph text. You won't see this.
<span>here is some footer stuff. You won't see this either.</span>
</p>
<!--This shows the same paragraph elements without the attribute component, which obviously will show up.-->
<p>
Here is some paragraph text without the custom attribute. You WILL see this.
<span>here is some footer stuff. You WILL see this too.</span>
</p>
使用组件,显示丢失的内容:
<xsl:template match="entry[string[1]='KEY2'][../entry[string[1]='KEY4' and string[2]='special_value']]/string[2]">
<xsl:copy>
<xsl:value-of select="replace(., 'x', 'y')"/>
</xsl:copy>
</xsl:template>