放置许可证密钥时出现问题的Angular2 ag-grid-enterprise项目

时间:2017-02-03 06:36:38

标签: angular typescript ag-grid

我拥有ag-grid-enterprise版本的许可,但我没有得到如何放置它以及如何在我的angular2项目中导入企业。

我试图使用licenseManager将许可证放在main.ts文件中 并将企业版本放在package.json和systemjs.config.json

但我收到的错误为click here to see image

systemjs.config.js:

'ag-grid': 'node_modules/ag-grid',
'ag-grid-ng2': 'node_modules/ag-grid-ng2',
'ag-grid-enterprise': 'node_modules/ag-grid-enterprise'
'ag-grid': {
   defaultExtension: "js"
 },
 'ag-grid-ng2': {
   defaultExtension: "js"
 },
 'ag-grid-enterprise': {
   defaultExtension: "js"
 }

的package.json

"dependencies": {
    "ag-grid": "7.1.x",
    "ag-grid-enterprise": "7.1.x",
    "ag-grid-ng2": "7.1.x",

    "@angular/common": "2.4.x",
    "@angular/compiler": "2.4.x",
    "@angular/compiler-cli": "2.4.x",
    "@angular/core": "2.4.x",
    "@angular/http": "2.4.x",
    "@angular/forms": "2.4.x",
    "@angular/platform-browser": "2.4.x",
    "@angular/platform-browser-dynamic": "2.4.x",
    "@angular/platform-server": "2.4.x",
    "@angular/router": "3.4.x",
    "rxjs": "5.0.x",
    "zone.js": "0.7.x",
    "core-js": "2.4.x",
    "systemjs": "0.19.27",
    "bootstrap": "3.3.6",
    "jquery": "3.1.1"
  },
  "devDependencies": {
    "@types/node": "6.0.45",
    "concurrently": "2.2.0",
    "typescript": "2.0.3",
    "rimraf": "2.5.x",
    "gulp": "3.9.1",
    "lite-server": "2.2.2",
    "systemjs-builder": "0.15.33",
    "copyfiles": "1.0.x",
    "ncp": "2.0.x",

    "@types/selenium-webdriver": "2.53.33",
    "http-server": "^0.9.0",
    "canonical-path": "0.0.2",
    "jasmine-core": "2.4.1",
    "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",
    "karma-systemjs": "0.16.0",
    "protractor": "4.0.13",
    "webdriver-manager": "10.2.5"
  }

main.ts

import {LicenseManager} from "ag-grid-enterprise/main";
LicenseManager.setLicenseKey("your license key");

"错误:错误:XHR错误(404 Not Found)loading http://localhost:3000/node_modules/ag-grid         在XMLHttpRequest.wrapFn [as _onreadystatechange](http://localhost:3000/node_modules/zone.js/dist/zone.js:1039:29)[]         在Zone.runTask(http://localhost:3000/node_modules/zone.js/dist/zone.js:151:47)[=> ]         在XMLHttpRequest.ZoneTask.invoke(http://localhost:3000/node_modules/zone.js/dist/zone.js:345:33)[]     将http://localhost:3000/node_modules/ag-grid加载为" ag-grid"时出错来自http://localhost:3000/node_modules/ag-grid-enterprise/dist/lib/menu/enterpriseMenu.js     at addToError(http://localhost:3000/node_modules/systemjs/dist/system.src.js:123:78)[]     在linkSetFailed(http://localhost:3000/node_modules/systemjs/dist/system.src.js:726:21)[]     在http://localhost:3000/node_modules/systemjs/dist/system.src.js:522:9 []     在Zone.run(http://localhost:3000/node_modules/zone.js/dist/zone.js:113:43)[=> ]     在http://localhost:3000/node_modules/zone.js/dist/zone.js:535:57 []     在Zone.runTask(http://localhost:3000/node_modules/zone.js/dist/zone.js:151:47)[=> ]     在drainMicroTaskQueue(http://localhost:3000/node_modules/zone.js/dist/zone.js:433:35)[]     在XMLHttpRequest.ZoneTask.invoke(http://localhost:3000/node_modules/zone.js/dist/zone.js:349:25)[]"

1 个答案:

答案 0 :(得分:1)

尝试引用真正的ag-grid主要js文件

System.config({
    defaultJSExtensions: true,
    map: {
        // angular libraries

        // ag libraries
        'ag-grid-ng2': 'node_modules/ag-grid-ng2',
        'ag-grid': 'node_modules/ag-grid',
        'ag-grid-enterprise': 'node_modules/ag-grid-enterprise'
    },
    packages: {
       // code ...
       'ag-grid': {
            main: 'main.js'
        }
    }
});