如果 systemJS(未尝试使用 webpack),Kendo UI 网格对我来说可以正常工作
这就是我的组件的样子-
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: `
<h5>My First Kendo UI grid with Angular 2 App</h5>
<h5>kendo-grid</h5>
<kendo-grid [data]="gridData">
<kendo-grid-column field="ProductName">
<template kendoHeaderTemplate let-column let-columnIndex="columnIndex">
{{column.field}}({{columnIndex}})
</template>
</kendo-grid-column>
<kendo-grid-column field="UnitPrice">
<template kendoHeaderTemplate let-column let-columnIndex="columnIndex">
{{column.field}}({{columnIndex}})
</template>
</kendo-grid-column>
</kendo-grid>
`
})
export class AppComponent {
private gridData: any[] = [{
"ProductID": 1,
"ProductName": "Chai",
"UnitPrice": 18.0000,
"Discontinued": true
}, {
"ProductID": 2,
"ProductName": "Chang",
"UnitPrice": 19.0000,
"Discontinued": false
}, {
"ProductID": 3,
"ProductName": "Aniseed Syrup",
"UnitPrice": 10.0000,
"Discontinued": false
}, {
"ProductID": 4,
"ProductName": "Chef Anton's Cajun Seasoning",
"UnitPrice": 22.0000,
"Discontinued": false
}, {
"ProductID": 5,
"ProductName": "Chef Anton's Gumbo Mix",
"UnitPrice": 21.3500,
"Discontinued": false
}, {
"ProductID": 6,
"ProductName": "Grandma's Boysenberry Spread",
"UnitPrice": 25.0000,
"Discontinued": false
}];
}
在 AppModule 中,像这样导入 GridModule -
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { GridModule } from '@progress/kendo-angular-grid';
import { AppComponent } from './app.component';
@NgModule({
imports: [ BrowserModule, GridModule],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
在 systemjs.config.js-
map: {
// our app is within the app folder
app: 'app',
'@progress/kendo-angular-grid': 'npm:@progress/kendo-angular-grid',
'@progress/kendo-angular-intl': 'npm:@progress/kendo-angular-intl',
'@telerik/kendo-intl': 'npm:@telerik/kendo-intl',
.......
// packages tells the System loader how to load when no filename and/or no extension
packages: {
'npm:@progress/kendo-angular-grid': {
main: './dist/npm/js/main.js',
defaultExtension: 'js'
},
'npm:@progress/kendo-angular-intl': {
main: './dist/npm/js/main.js',
defaultExtension: 'js'
},
'npm:@telerik/kendo-intl': {
main: './dist/npm/js/main.js',
defaultExtension: 'js'
},
.......
在 index.html-
<link rel="stylesheet" href="../node_modules/@progress/kendo-angular-grid/dist/npm/css/main.css">
输出看起来像这样 -
我的环境是-
Angular2 版本:最终 2.0.0
@进步/剑道角网格:0.3.3
看看这是否有帮助。