问题
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