我有一个自定义组件的装饰器:
export const MyDecorator = () => {
return (constructor: Function) => {
constructor.prototype['ngAfterViewInit'] = function() {
// I need to get component's view child here
};
};
};
我需要在decorator中获得一个view子元素。在组件中,我可以使用@viewchild decorator获取此元素:
@MyDecorator()
@Component({
selector: "app-my-component",
templateUrl: "./my-component.html"
})
export class MyPage {
@ViewChild(Content) content: Content;
}
如何在mydecorator中获取content元素?