【发布时间】:2020-05-14 14:52:35
【问题描述】:
从父级获取计算出的子组件角度高度的最佳方法是什么?我有一个像下面这样的组件
import { Component, ViewChild } from 'angular2/core';
(...)
@Component({
selector: 'my-app',
template: `
<h1>My Add Angular 8 app</h1>
<ng-container *ngFor="let item of list>
<child #Children [content]="item.content" [id]="id"></child>
<ng-container>
<button (click)="submit()">Submit</button>
`,
})
export class AppComponent implements AfterViewInit {
@ViewChild(Children) Children: QueryList<ElementRef>;
(...)
ngAfterViewInit() {
console.log("The children are", this.Children.toArray())
/*==> give me aray of Child component with the props , id and content,
i need the computer nativeElement to be able to get the height. */
}
}
请问从父组件获取子组件 offsetHeight 的最佳方法是什么?任何帮助将不胜感激
【问题讨论】:
标签: angular