i'm trying to use ag-grid in angular1 project

*爱你&永不变心* 提交于 2020-01-04 10:45:46

问题


I'm in Jhipster starter with angular 1 project. I have some problems withe ag-grid component.

first one: i use bower for all my component and wiredep include my ag-grid file before the angular.js file. I think i solve this by using overrides, but i'm not sure of me I set this on overrides in bower.json.

"ag-grid": {
  "dependencies": {
    "angular": "*"
  }
}

ag-grid is well after angular.js now but i still have an other problem.

in my console i have this "Uncaught ReferenceError: require is not defined" cause by the bower_components/ag-grid/main.js code here :

var populateClientExports = require('./dist/lib/clientExports').populateClientExports;

populateClientExports(exports);

i don't know what happen, if it's my override not working or something else.

Thanks you for your help.


回答1:


First, the override should be correct. you can simply check the override, if you look into the index.html and check the order of the included scripts.

Secondly, ag grid uses commonjs to load the files. But Jhipster does not use common js. so, you have to use the non-commonjs version of ag grid. If my quick view into the docs are right, you must use another version of ag grid. For this, you have to override the main file in your bower.json, so wiredep will pick up this one. Therefore, this

"ag-grid": {
   "dependencies": {
    "angular": "*"
  },
  "main": [
   "dist/ag-grid.js"
  ]
}

should load the non-commonjs version



来源:https://stackoverflow.com/questions/41100820/im-trying-to-use-ag-grid-in-angular1-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!