我想获取当前的元数据NgModule为了得到列表declarations
and providers
为了填充动态模块,我创建了一个在模态中显示组件的模块。
那怎么办呢?
您可以使用以下方式访问声明reflect-metadata https://github.com/rbuckton/reflect-metadata包裹。但是,您确实需要安装此软件包并将其包含在您的项目中。之后你可以得到这样的注释:
let annotations: DecoratorFactory[] = Reflect.getMetadata('annotations', ModuleClass);
If the @NgModule
是那里唯一的注释,我猜它是,你可以像这样访问声明,否则你必须猜测正确的index
:
let declarations: any[] = annotations[0].declarations;
看到这个answer https://stackoverflow.com/a/34466523/3106920供进一步参考
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)