Angular 将条件指令写入标记

Angular Write a conditional directive to a tag

我想向标签添加指令,例如

<div class="test" directive></div>

我厌倦了使用三元运算符来写条件,如果条件为真我想显示否则为空

<div class="test" {{(checkName==true?'directive':'')}}></div>

无法 add/remove 动态地向元素或组件发出指令。

指令仅添加到静态添加到组件模板的选择器。

另见 https://github.com/angular/angular/issues/6970