【发布时间】:2018-04-16 05:40:46
【问题描述】:
是否可以在 Angular 2 中使用选择器名称获取组件类名或组件引用?
@Component({
selector: 'selector-1',
template: '<h1>Hello</h1>',
})
export class Component1 {}
@Component({
selector: 'selector-2',
template: '<h1>Hello</h1>',
})
export class Component2 {}
在组件 2 中是否可以使用选择器“selector-1”获取组件 1 的类名?
示例:
getComponentName(selectorName) {
// return component name
}
getComponentName('selector-1');
提前致谢
【问题讨论】:
标签: angular typescript annotations angular2-components angular2-decorators