【发布时间】:2017-12-11 06:57:23
【问题描述】:
在以下链接的自定义结构指令示例中,TemplateRef 和 ViewContainerRef 指向什么?
https://angular.io/guide/structural-directives#unless
指令通常没有视图。那么 templateRef 是否会指向该指令所附加的 HTML 标记或组件?例如,在下面的代码中,模板是<p> ...</p> 之间的所有内容?我读到* 被转换为<ng-template> 所以可能是这种情况。
<p *myUnless="condition">Show this sentence unless the condition is true.</p>
示例中的 ViewContainerRef 是什么?通常我会添加一个<ng-container> 作为视图容器?在示例中它来自哪里?
【问题讨论】:
标签: angular