【发布时间】:2017-05-15 16:02:12
【问题描述】:
我目前正在尝试在我的 angular2 项目中注入 ag-grid,但在渲染它时遇到了问题。
我正在尝试使用这个 ag-grid package 并按照教程使用命令“dotnet new angular”生成的 .net 项目。
这是我的 agGrid.component.ts :
import { Component } from '@angular/core';
import { GridOptions } from "ag-grid/main";
@Component({
selector: 'ag-grid-component',
templateUrl: './agGrid.component.html'
})
export class AgGridComponent {
private gridOptions: GridOptions;
public rowData: any[];
private columnDefs: any[];
constructor() {
this.gridOptions = <GridOptions>{};
this.createRowData();
this.createColumnDefs();
this.gridOptions.defaultColDef = {
headerComponentParams: {
menuIcon: 'fa-bars'
}
}
}
private createRowData() {
this.rowData = [
{ make: "Toyota", model: "Celica", price: 35000 },
{ make: "Ford", model: "Mondeo", price: 32000 },
{ make: "Porsche", model: "Boxter", price: 72000 }
];
}
private createColumnDefs() {
this.columnDefs = [
{ headerName: "Make", field: "make" },
{ headerName: "Model", field: "model" },
{ headerName: "Price", field: "price" }
];
}
}
还有我的 agGrid.component.html :
<ag-grid-angular #agGrid style="width:500px;height:200px" class="ag-fresh"
[gridOptions]="gridOptions"
[columnDefs]="columnDefs"
[rowData]="rowData">
</ag-grid-angular>
我小心地从“ag-grid-angular/main”导入了 AgGridModule,但结果很糟糕:
有人可以请教我吗?提前谢谢你。
【问题讨论】:
-
看起来您没有获取 css 文件,这些文件是在某处导入的吗?
标签: asp.net angular npm webpack ag-grid