SAP Spartacus里ng-template的一个实际应用

时间:2022-07-26
本文章向大家介绍SAP Spartacus里ng-template的一个实际应用,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

Structural directives are responsible for HTML layout. They shape or reshape the DOM’s structure, typically by adding, removing, or manipulating elements.

Angular consumed the content during its actual rendering and replaced the with a diagnostic comment.

The is an Angular element for rendering HTML. It is never displayed directly. In fact, before rendering the view, Angular replaces the and its contents with a comment.

If there is no structural directive and you merely wrap some elements in a , those elements disappear. That’s the fate of the middle “Hip!” in the phrase “Hip! Hip! Hooray!”.

看个例子:

<p>Hip!</p>
<ng-template>
  <p>Hip!</p>
</ng-template>
<p>Hooray!</p>

最终效果: