Closed martinmasse closed 7 years ago
Bootstrap requires jQuery to be in the global scope. But, we are loading jQuery as a module. They are not compatible by default. I've attached a sample project created using Angular-CLI. The project loads a simple module as the following:
var $ = require("jquery");
alert($.fn.jquery);
As you can see, you are getting the error that 'jquery' is undefined. If you clear the scripts
of the angular-cli.json
file, you see that this module does work. To handle this scenario, it's necessary to customize the Webpack configuration file to use the ProvidePlugin
as illustrated in the https://github.com/GoshaFighten/Angular2DXWebpackDotNetCore/blob/master/webpack.config.vendor.js#L45 line. But, Angular-CLI does not provide an API to specify this. See the https://github.com/angular/angular-cli/issues/1656 issue on the Angular-CLI repository. I suggest you use an Angular project with Webpack without Angular-CLI.
GH307.zip
Ok thanks. Il will do that.
Use angular-cli 1.0.0-beta.30 (Now: @angular/cli@1.0.0-beta.30), and @ngtools/webpack@1.2.4 for tenmporal fix (https://github.com/angular/angular-cli/issues/4338).
` "dependencies": { "@angular/common": "^2.4.6", "@angular/compiler": "^2.4.6", "@angular/core": "^2.4.6", "@angular/forms": "^2.4.6", "@angular/http": "^2.4.6", "@angular/material": "^2.0.0-beta.1", "@angular/platform-browser": "^2.4.6", "@angular/platform-browser-dynamic": "^2.4.6", "@angular/router": "^3.4.6", "@ngtools/webpack": "^1.2.4", "bootstrap": "^3.3.7", "core-js": "^2.4.1", "devextreme": "^16.2.4", "devextreme-angular": "^16.2.4", "jquery": "3.1.1", "modernizr": "^3.3.1", "moment": "^2.17.1", "ng2-bootstrap": "^1.3.3", "node-sass": "^4.5.0", "rxjs": "5.1.0", "screenfull": "^3.0.2", "simple-line-icons": "^2.4.1", "spinkit": "^1.2.5", "ts-helpers": "^1.1.2", "zone.js": "^0.7.6" }, "devDependencies": { "@angular/cli": "1.0.0-beta.30", "@angular/compiler-cli": "^2.4.6", "@ngtools/webpack": "^1.2.4", "@types/jasmine": "^2.5.41", "@types/node": "^7.0.4", "codelyzer": "~2.0.0-beta.4", "jasmine-core": "2.5.2", "jasmine-spec-reporter": "3.2.0", "karma": "1.4.1", "karma-chrome-launcher": "^2.0.0", "karma-cli": "^1.0.1", "karma-jasmine": "^1.1.0", "karma-read-json": "^1.1.0", "karma-remap-istanbul": "^0.5.0", "loaders.css": "^0.1.2", "napa": "^2.3.0", "protractor": "5.1.0", "ts-node": "2.0.0", "tslint": "3.x.x", "typescript": "2.1.5" }
Hi,
I have followed the instructions to add devextreme to a Angular-CLI generated application. It work fine.
Problems start when I add Bootstrap 4 using the instructions found on that page https://github.com/angular/angular-cli
Then I get the following error.
Uncaught TypeError: Cannot read property 'jquery' of undefined at Object. (deferred.js:25)
at webpack_require (bootstrap c038965…:52)
at Object. (common.js:12)
at webpack_require (bootstrap c038965…:52)
at Object. (string.js:11)
at webpack_require (bootstrap c038965…:52)
at Object. (error.js:12)
at webpack_require (bootstrap c038965…:52)
at Object. (errors.js:10)
at webpack_require (bootstrap c038965…:52)
at Object. (fx.js:11)
at webpack_require (bootstrap c038965…:52)
at Object. (accordion.js:11)
at __webpack_require__ (bootstrap c038965…:52)
at Object. (accordion.js:20)
Bootstrap 4 works fine if devextreme is not added to the app.
Any idea how to solve this issue?
Thanks