【发布时间】:2017-06-11 13:41:14
【问题描述】:
我在 *ngFor 中有一个动态创建的组件,我如何在 ViewChildren 中获取这些组件的 offsettop 和 offsetleft。
模板
<anchor #myanchor></anchor>
类
@ViewChildren('myanchor') anchors: QueryList<any>;
这里是 ngAfterViewInit
ngAfterViewInit(){
this.anchors.map(i=>{ console.log(i); })
}
我可以通过 ViewChild 获得单个元素的位置,但需要 ViewChildren 的帮助。任何指针将不胜感激。
【问题讨论】: