异常:html 中的错误,原因是:没有 Ng2FrameworkFactory 的提供者! ag-grid-ng2
EXCEPTION: Error in html caused by: No provider for Ng2FrameworkFactory! ag-grid-ng2
我收到错误异常:app/../html:0:0 中的错误,原因是:没有 Ng2FrameworkFactory 的提供者!在 core.umd.js。
package.json 如下
{
"name": "angular-quickstart",
"version": "1.0.0",
"description": "QuickStart package.json from the documentation, supplemented with testing support",
"scripts": {
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
"e2e": "tsc && concurrently \"http-server -s\" \"protractor protractor.config.js\" --kill-others --success first",
"lint": "tslint ./app/**/*.ts -t verbose",
"lite": "lite-server",
"pree2e": "webdriver-manager update",
"test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
"test-once": "tsc && karma start karma.conf.js --single-run",
"tsc": "tsc",
"tsc:w": "tsc -w"
},
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
"@angular/common": "~2.4.0",
"@angular/compiler": "~2.4.0",
"@angular/core": "~2.4.0",
"@angular/forms": "~2.4.0",
"@angular/http": "~2.4.0",
"@angular/platform-browser": "~2.4.0",
"@angular/platform-browser-dynamic": "~2.4.0",
"@angular/router": "~3.4.0",
"@types/jquery": "^2.0.37",
"angular-in-memory-web-api": "~0.2.2",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.1",
"systemjs": "0.19.40",
"zone.js": "^0.7.4",
"ag-grid": "7.1.0",
"ag-grid-ng2": "7.1.1"
},
"devDependencies": {
"@types/jasmine": "^2.5.36",
"@types/jquery": "^2.0.37",
"@types/node": "^6.0.46",
"canonical-path": "0.0.2",
"concurrently": "^3.1.0",
"http-server": "^0.9.0",
"jasmine-core": "~2.4.1",
"jquery": "^2.2.3",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-jasmine-html-reporter": "^0.2.2",
"lite-server": "^2.2.2",
"lodash": "^4.16.4",
"protractor": "~4.0.14",
"rimraf": "^2.5.4",
"tslint": "^3.15.1",
"typescript": "~2.0.10"
},
"repository": {}
}
模块 ts 如下所示
import {AgGridModule} from 'ag-grid-ng2/main';
@NgModule({
imports: [CommonModule, FormsModule, HttpModule, AgGridModule]
组件中
import {GridOptions} from 'ag-grid/main';
this.columnDefs = [..];
this.gridOptions = {};
在html模板中,
<ag-grid-ng2 #agGrid style="width: 100%; height: 350px;" class="ag-fresh"
[gridOptions]="gridOptions"
[columnDefs]="columnDefs"
[rowData]="rowData"
enableColResize
enableSorting
enableFilter
rowHeight="22">
我做错了什么?
如果您查看 ag-Grid 文档 (https://www.ag-grid.com/best-angular-2-data-grid/),您会发现在导入 ag-Grid 时需要这样做:
AgGridModule.withComponents([...optional Angular 2 Components to be used in the grid....]]),
我收到错误异常:app/../html:0:0 中的错误,原因是:没有 Ng2FrameworkFactory 的提供者!在 core.umd.js。 package.json 如下
{
"name": "angular-quickstart",
"version": "1.0.0",
"description": "QuickStart package.json from the documentation, supplemented with testing support",
"scripts": {
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
"e2e": "tsc && concurrently \"http-server -s\" \"protractor protractor.config.js\" --kill-others --success first",
"lint": "tslint ./app/**/*.ts -t verbose",
"lite": "lite-server",
"pree2e": "webdriver-manager update",
"test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
"test-once": "tsc && karma start karma.conf.js --single-run",
"tsc": "tsc",
"tsc:w": "tsc -w"
},
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
"@angular/common": "~2.4.0",
"@angular/compiler": "~2.4.0",
"@angular/core": "~2.4.0",
"@angular/forms": "~2.4.0",
"@angular/http": "~2.4.0",
"@angular/platform-browser": "~2.4.0",
"@angular/platform-browser-dynamic": "~2.4.0",
"@angular/router": "~3.4.0",
"@types/jquery": "^2.0.37",
"angular-in-memory-web-api": "~0.2.2",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.1",
"systemjs": "0.19.40",
"zone.js": "^0.7.4",
"ag-grid": "7.1.0",
"ag-grid-ng2": "7.1.1"
},
"devDependencies": {
"@types/jasmine": "^2.5.36",
"@types/jquery": "^2.0.37",
"@types/node": "^6.0.46",
"canonical-path": "0.0.2",
"concurrently": "^3.1.0",
"http-server": "^0.9.0",
"jasmine-core": "~2.4.1",
"jquery": "^2.2.3",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-jasmine-html-reporter": "^0.2.2",
"lite-server": "^2.2.2",
"lodash": "^4.16.4",
"protractor": "~4.0.14",
"rimraf": "^2.5.4",
"tslint": "^3.15.1",
"typescript": "~2.0.10"
},
"repository": {}
}
模块 ts 如下所示
import {AgGridModule} from 'ag-grid-ng2/main';
@NgModule({
imports: [CommonModule, FormsModule, HttpModule, AgGridModule]
组件中
import {GridOptions} from 'ag-grid/main';
this.columnDefs = [..];
this.gridOptions = {};
在html模板中,
<ag-grid-ng2 #agGrid style="width: 100%; height: 350px;" class="ag-fresh"
[gridOptions]="gridOptions"
[columnDefs]="columnDefs"
[rowData]="rowData"
enableColResize
enableSorting
enableFilter
rowHeight="22">
我做错了什么?
如果您查看 ag-Grid 文档 (https://www.ag-grid.com/best-angular-2-data-grid/),您会发现在导入 ag-Grid 时需要这样做:
AgGridModule.withComponents([...optional Angular 2 Components to be used in the grid....]]),