【发布时间】:2017-10-08 21:23:48
【问题描述】:
<!--snippet from template file-->
<custom-component
... other properties
(mousedown)="onMouseDown()"
</custom-component>
@Component({
//selector and templateURL
})
class ContainerComponent{
onMouseDown(){
//get the reference to the custom component here
}
}
所以我的模板文件中有多个自定义组件指向同一个mousedown 事件我如何获得对customComponent 的引用。我想要对组件的真正引用而不是对本机元素的引用,我希望它与 @ViewChild() 事物进行比较。
【问题讨论】:
-
custom-component和ContainerComponent是什么关系? -
custom-component是ContainterComponent的子组件,ContainerComponent 的 html 文件中使用了自定义组件选择器
标签: angular angular2-template angular2-services angular2-directives