如何在Angular的grid元素上获取DOM参考?似乎没有直接的方法。我试过了:
标记:
<ag-grid-angular #logGrid></ag-grid-angular>
ts:
@ViewChild('logGrid') logGrid: AgGridNg2;
AgGridNg2没有公开nativeElement或ElementRef属性。
我也尝试过:
@ViewChild('logGrid') logGrid: ElementRef;
它没有nativeElement属性,因为它的类型是AgGridNg2而不是ElementRef。
我需要DOM参考,因为ag-grid不公开其内容的scrollHeight。
您可以通过将ViewChild装饰器的read
属性设置为来获得对该组件的host元素的引用:ElementRef
@ViewChild('logGrid', { read: ElementRef }) logGridElementRef: ElementRef;
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句