有没有办法在我的app.module.ts文件中获取“#content”变量?
我的HTML示例文件
<div #content>
.....
</div>
我的示例app.module.ts文件
//How do I get my variable here?
答案 0 :(得分:1)
您可以通过以下方式访问它:
@ViewChild('content') content: ElementRef;
在这里有更深入的了解: https://medium.com/@toannm4/angular-nativeelement-how-to-read-nativeelement-using-viewchild-cdf4a0970482