为什么这个带有 ag-grid 的 TypeSctipt 示例不起作用?
控制台有错误:
EXCEPTION: No Directive annotation found on AgGridNg2
带有问题行的cars.ts代码:
import {Component, View} from 'angular2/angular2'
import {CarsService} from './cars_service'
@Component({
selector: 'cars',
bindings: [CarsService]
})
@View({
template: `
<ag-grid-ng2 id="cars" class="ag-fresh"
[column-defs]="columnDefs" [row-data]="rowData">
</ag-grid-ng2>
`,
////////////////////////////////////
// Problem at this line
////////////////////////////////////
directives: [ag.grid.AgGridNg2]
})
export class Cars {
private columnDefs: Object[];
private rowData: Object[];
constructor(service: CarsService) {
this.columnDefs = [
{ headerName: "Make", field: "make" },
{ headerName: "Model", field: "model" },
{ headerName: "Price", field: "price" }
];
service.getCars().subscribe(
(res: Response) => {
this.rowData = res.json();
//console.log(this.rowData);
// TODO: Refresh table
});
}
}
我是否必须导入 AgGridNg2 以及如何做?或者也许当前版本的 Angular2 Beta 已损坏?