我正在使用 Angular 5 和 ag-grid 17.x,我只是尝试做一个简单的“hello world”类型的示例,但无法正确显示网格。我的模板中有以下 HTML:
<div style="width: 800px; height: 500px" class="ag-theme-balham">
<ag-grid-angular
[rowData]="rowData"
[columnDefs]="columnDefs">
</ag-grid-angular>
</div>
...我没有收到任何错误,但它不是网格,而是呈现为一列混乱的文本。
不管怎样,我在开发工具中注意到网格指向的样式不存在,所以我将它们导入到 .angular-cli.json 中:
"styles": [
"scss/styles.scss",
"../node_modules/ag-grid/dist/styles/ag-grid.css",
"../node_modules/ag-grid/dist/styles/ag-theme-balhom.css"
],
...这有效,但解决方案对我来说似乎并不正确。我尝试将它们导入我的 .scss 文件之一:
@import '~ag-grid/src/styles/ag-grid.scss';
@import '~ag-grid/src/styles/ag-theme-fresh.scss';
...但出现了一堆参考错误(找不到图标等)。
My question is how should ag-grid styles and themes be imported into an Angular application? I've dug around in the documentation, but can't seem to find the solution that I stumbled upon, so assume it's wrong...but can't find anything that works either. Thanks for any help!