我正在尝试使用 Kendo 创建一个演示应用程序,我可以使用 Kendo UI 来完成。现在我需要使用 Angular 2 Kendo UI 来尝试相同的操作。但是我被以下错误卡住了。
我的组件代码是这样的。与 Kendo UI 中的示例代码相同。
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: `
<kendo-grid [data]="gridData">
<kendo-grid-column field="ProductID" title="Product ID" width="120">
</kendo-grid-column>
<kendo-grid-column field="ProductName" title="Product Name">
</kendo-grid-column>
<kendo-grid-column field="UnitPrice" title="Unit Price" width="230">
</kendo-grid-column>
<kendo-grid-column field="Discontinued" width="120">
<template kendoCellTemplate let-dataItem>
<input type="checkbox" [checked]="dataItem.Discontinued" disabled/>
</template>
</kendo-grid-column>
</kendo-grid>
`
})
export class GridComponent {
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
}];
}
我有一个带有以下详细信息的通用模块类
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { BookDetailComponent } from './distribution-detail/distribution-detail.component';
import { GridComponent } from './detail-grid/detail-grid.component';
import { GridModule } from '@progress/kendo-angular-grid';
@NgModule({
imports: [
CommonModule,
FormsModule,
SharedModule,
HttpModule,
GridModule
],
declarations: [
BookDetailComponent,
GridComponent
],
providers: [
DistributionService
]
})
export class DistributionModule { }
BookDetailComponent HTML 代码中使用了 Grid Module 选择器,
<my-app>Loading</my-app>
但是我得到了错误
core.umd.js:2837 例外:未捕获(承诺中):错误:模板解析错误:'grid-demo' 不是已知元素:1. 如果 'my-app' 是 Angular 组件,则验证它是本模块的一部分。