【发布时间】:2020-05-15 02:19:34
【问题描述】:
目标:包装 ag-grid-angular 组件,使用来自@input 的数据来设置 gridOptions。
//wrapper component
// .html
<ag-grid-angular
[gridOptions]="gridOptions"
[columnDefs]="..."
[rowData]="...">
</ag-grid-angular>
// .ts this works
export class GridComponent implements OnInit {
private gridOptions = {animateRows: true}
}
// this does not work (rows are not animated)
export class GridComponent implements OnInit {
@Input() rowAnimation: Boolean = false
private gridOptions = {}
ngOnInit() {
if (this.rowAnimation) {
this.gridOptions['animateRows'] = true
}
}
}
// component using wrapper
// .html
<app-grid [rowAnimation] ="true"> </app-grid>
问题很可能与在非工作示例中设置 @input 值之前的 gridOptions 绑定有关。但不知道如何解决这个问题。
【问题讨论】:
标签: angular ag-grid ag-grid-angular