首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >将自定义指令绑定到主机

将自定义指令绑定到主机
EN

Stack Overflow用户
提问于 2016-05-30 02:13:15
回答 1查看 7.4K关注 0票数 15

我到处找了看,但似乎找不到答案。我已经创建了一个指令,它工作得很好,但我想将它动态地绑定到组件的宿主上。

示例:

代码语言:javascript
复制
@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元素包装模板的需要

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-05-30 02:16:02

目前不支持此功能。

另请参阅https://github.com/angular/angular/issues/8785

票数 13
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37513283

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档