我正在使用反射元数据 0.1.2。我有一个父类作为“MyCustom”。
export class MyCustom {}
我的“Home”组件类扩展了这个“MyCustom”类。
@Component({
selector: 'home',
templateUrl: './app/components/home/home.html',
styleUrls: ['./app/components/home/home.css']
})
export class Home extends MyCustom {
}
我的意图是使用以下方法调用获取扩展“MyCustom”类的所有类的元数据。
let annotations = Reflect.getMetadata('annotations', MyCustom);
对 Reflect.getMetadata() 方法的评论说,
获取目标对象或其原型链上提供的元数据键的元数据值。
然而我什么也得不到。如果我将@Component 添加到“MyCustom”类,如下所示,
@Component({
selector: 'hello'
})
export class MyCustom {}
我得到一个结果,即“MyCustom”上的注释。
为什么我没有得到子类的注释?非常感谢任何帮助。