我到处找了看,但似乎找不到答案。我已经创建了一个指令,它工作得很好,但我想将它动态地绑定到组件的宿主上。
示例:
@Directive({ selector: 'myDirective' })
@Component({ selector: 'myComponent',
template: 'some content goes here...'
})
export class MyComponent {
/* bind myDirective to host */
}
//when using myComponent, it should be
<myComponent></myComponent>
//not
<myComponent myDirective></myComponent>
基本上,我希望消除a)显式设置myDirective
和b)使用myDirective
元素包装模板的需要
发布于 2016-05-30 02:16:02
目前不支持此功能。
https://stackoverflow.com/questions/37513283
复制相似问题