EXCEPTION: Error in html caused by: No provider for Ng2FrameworkFactory! ag-grid-ng2

1.1k Views Asked by At

I get the error EXCEPTION: Error in app/../html:0:0 caused by: No provider for Ng2FrameworkFactory! in core.umd.js. The package.json is as below

{
"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": {}
}

The module ts looks like the below

import {AgGridModule} from 'ag-grid-ng2/main';

@NgModule({
imports: [CommonModule, FormsModule, HttpModule, AgGridModule]

In the component

import {GridOptions} from 'ag-grid/main';
this.columnDefs = [..];
this.gridOptions = {};

In the html template,

<ag-grid-ng2 #agGrid style="width: 100%; height: 350px;" class="ag-fresh"    
[gridOptions]="gridOptions"
[columnDefs]="columnDefs"
[rowData]="rowData"    
enableColResize
enableSorting
enableFilter   
rowHeight="22">

What am I doing wrong ?

1

There are 1 best solutions below

0
On BEST ANSWER

If you take a look at the ag-Grid Docs (https://www.ag-grid.com/best-angular-2-data-grid/) you'll see you need to do this when importing ag-Grid:

AgGridModule.withComponents([...optional Angular 2 Components to be used in the grid....]]),