【发布时间】:2019-09-06 15:56:58
【问题描述】:
我正在使用 ag-grid 作为框架来构建我的网格(显然)。
我遵循了一个简单的教程。所以这是到目前为止的代码,
typography.component.ts
import {Component} from "@angular/core";
import {GridOptions} from "ag-grid-community";
@Component({
selector: 'typography-cmp',
moduleId: module.id,
templateUrl: 'typography.component.html'
})
export class TypographyComponent {
private gridOptions: GridOptions;
constructor() {
this.gridOptions = <GridOptions>{};
this.gridOptions.columnDefs = [
{
headerName: "ID",
field: "id",
width: 100
},
{
headerName: "Value",
field: "value",
width: 100
},
];
this.gridOptions.rowData = [
{id: 5, value: 10},
{id: 10, value: 15},
{id: 15, value: 20}
]
}
}
这非常有效。但是,您可能已经在 html 文件中注意到:
网格选项
以红色为底色。 这就是为什么:
标识符'gridOptions'指的是组件的私有成员
这是可以理解的。我正在关注官方教程。我想知道代码是否违反了任何编码规则或最佳实践?
谢谢。
【问题讨论】:
标签: html node.js angular typescript ag-grid