例外:在没有找到AgGridNg2标注指令 [英] EXCEPTION: No Directive annotation found on AgGridNg2

查看:487
本文介绍了例外:在没有找到AgGridNg2标注指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个例子上TypeSctipt ,提供AG-电网不工作?

Why this example on TypeSctipt with ag-grid isn't work?

有没有错误控制台:

EXCEPTION: No Directive annotation found on AgGridNg2

cars.ts的

code。与poblem行:

Code of cars.ts with poblem line:

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版也许当前版本坏了?

Must I import AgGridNg2 or not and how to do it? Or maybe current version of Angular2 Beta is broken?

推荐答案

我看看你的plunkr。在beta版本, angular2 / angular2 现在 angular2 /芯

I had a look at your plunkr. In beta versions, angular2/angular2 is now angular2/core.

这是说,看来你不正确初始化AG-网格。你应该尝试这样的事情:

That said, it seems that you don't correctly initialize ag-grid. You should try something like that:

ag.grid.initialiseAgGridWithAngular2({ core: core });

bootstrap(App, [
    HTTP_BINDINGS,
    ROUTER_BINDINGS,
    bind(ROUTER_PRIMARY_COMPONENT).toValue(App),
    bind(LocationStrategy).toClass(HashLocationStrategy)
]);

和从删除此块的index.html 文件:

System.import("angular2/angular2").then(function(ng2) {
  ag.grid.initialiseAgGridWithAngular2(ng2);
});

下面是使用AG-电网与打字稿的示例:的https:/ /github.com/helix46/ag-grid-angular2-beta-ts 。下面是关于配置文件:的https: //github.com/helix46/ag-grid-angular2-beta-ts/blob/master/src/boot.ts

Here is a sample of use of ag-grid with TypeScript: https://github.com/helix46/ag-grid-angular2-beta-ts. Here is the file regarding configuration: https://github.com/helix46/ag-grid-angular2-beta-ts/blob/master/src/boot.ts.

希望它可以帮助你,
蒂埃里

Hope it helps you, Thierry

这篇关于例外:在没有找到AgGridNg2标注指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆