首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >模块ag-grid-angular/main没有导出的成员AgGridNg2.ts

模块ag-grid-angular/main没有导出的成员AgGridNg2.ts
EN

Stack Overflow用户
提问于 2019-06-20 05:04:38
回答 2查看 3.8K关注 0票数 3

我在我的Angular 7应用中安装了ag-grid,并在Enable Selection for ag-grid上学习了ag-grid教程。当我尝试导入AgGridNg2时,我得到了Module ag-grid-angular/main has no exported member AgGridNg2.ts。我只能假设这个插件的文档已经过期了。我需要修复什么才能使其正常工作?这是我的component.ts:

代码语言:javascript
复制
import { Component, OnInit, Inject, ViewChild } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { AgGridNg2 } from 'ag-grid-angular';

@Component({
  selector: 'app-sample',
  templateUrl: './sample.component.html',
  styleUrls: ['./sample.component.css']
})
export class SampleComponent implements OnInit {
  @ViewChild('agGrid') agGrid: AgGridNg2;
      columnDefs = [
        {headerName: 'Make', field: 'make', sortable: true, filter: true, checkboxSelection: true },
        {headerName: 'Model', field: 'model', sortable: true, filter: true },
        {headerName: 'Price', field: 'price', sortable: true, filter: true }
    ];

rowData: any;

  constructor(private http: HttpClient) {

    }

  ngOnInit() {
    this.rowData = this.http.get('https://api.myjson.com/bins/15psn9');
  }

}

编辑:这里是package.json

代码语言:javascript
复制
{
  "name": "webapplication12",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "build:ssr": "ng run WebApplication12:server:dev",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "7.2.5",
    "@angular/common": "7.2.5",
    "@angular/compiler": "7.2.5",
    "@angular/core": "7.2.5",
    "@angular/forms": "7.2.5",
    "@angular/http": "7.2.5",
    "@angular/platform-browser": "7.2.5",
    "@angular/platform-browser-dynamic": "7.2.5",
    "@angular/platform-server": "7.2.5",
    "@angular/router": "7.2.5",
    "@nguniversal/module-map-ngfactory-loader": "7.1.0",
    "ag-grid-angular": "^21.0.1",
    "ag-grid-community": "^21.0.1",
    "ag-grid-ng2": "^8.0.0",
    "aspnet-prerendering": "^3.0.1",
    "bootstrap": "^4.3.1",
    "core-js": "^2.6.5",
    "jquery": "3.3.1",
    "oidc-client": "^1.6.1",
    "popper.js": "^1.14.3",
    "rxjs": "^6.4.0",
    "zone.js": "^0.8.29"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.13.5",
    "@angular/cli": "~7.3.5",
    "@angular/compiler-cli": "^7.2.8",
    "@angular/language-service": "^7.2.5",
    "@types/jasmine": "~3.3.9",
    "@types/jasminewd2": "~2.0.6",
    "@types/node": "~11.10.5",
    "codelyzer": "~4.5.0",
    "jasmine-core": "~3.3.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^4.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.5",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "typescript": "~3.2.4"
  },
  "optionalDependencies": {
    "node-sass": "^4.9.3",
    "protractor": "~5.4.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1"
  }
}
EN

回答 2

Stack Overflow用户

发布于 2019-06-25 19:28:45

尝试使用AgGridAngular而不是AgGridNg2,如下所示

代码语言:javascript
复制
import { AgGridAngular } from 'ag-grid-angular';
...
@ViewChild('agGrid') agGrid: AgGridAngular;
票数 6
EN

Stack Overflow用户

发布于 2019-10-04 18:56:13

我使用Angular 8和@ViewChild('agGrid')期望2个参数(但得到了1),所以对我有效的方法很简单:

代码语言:javascript
复制
import { AgGridAngular } from 'ag-grid-angular';
...
private agGrid: AgGridAngular;
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56675817

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档