Angular2 ag-grid-enterprise 项目在放置许可证密钥时遇到问题
Posted
技术标签:
【中文标题】Angular2 ag-grid-enterprise 项目在放置许可证密钥时遇到问题【英文标题】:Angular2 ag-grid-enterprise project having issue while placing License Key 【发布时间】:2017-06-20 11:11:45 【问题描述】:我有 ag-grid-enterprise 版本的许可证,但我不知道如何放置它以及如何在我的 angular2 项目中导入企业。
我正在尝试使用 licenseManager 将许可证放在 main.ts 文件中 并将企业的版本放在package.json和systemjs.config.json中
但我收到错误
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"
包.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 未找到)正在加载 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-enterprise/dist/lib/menu/enterpriseMenu.js 将http://localhost:3000/node_modules/ag-grid 加载为“ag-grid”时出错 在 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) []"
【问题讨论】:
尝试引用真正的 ag-grid 主 js 文件。packages: // ... 'ag-grid': main: 'main.js'
@TiepPhan 表示'ag-grid': main: "main.js" ,
thanx @TiepPhan 现在它正在工作
是的,将会话包更改为类似github.com/ceolter/ag-grid-ng2-example/blob/master/systemjs_aot/…
您好 - 如果您是企业客户,您应该在会员论坛上发帖:ag-grid.com/forum/forumdisplay.php?fid=5 - 您将很快获得支持
【参考方案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'
);
【讨论】:
以上是关于Angular2 ag-grid-enterprise 项目在放置许可证密钥时遇到问题的主要内容,如果未能解决你的问题,请参考以下文章
Angular2 [innerHtml] angular2 标签不起作用
Angular2 Dart - 在 Angular2 组件中获取文本
RangeError,谷歌地图方向服务。 angular2, SebastianM/angular2-google-maps