2

No matter what I do, I cant seem to get jquery imported before bootstrap wants to use it.

Here is my app.js

// JQuery libary needed for bootstrap
import 'jquery/dist/jquery.min.js';

// Bootstrap libary
import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap/dist/js/bootstrap.js';

// Bootstrap-select libary 
import 'bootstrap-select/dist/css/bootstrap-select.css';
import 'bootstrap-select/dist/js/bootstrap-select.js';

// Angular-material standard CSS 
import 'angular-material/angular-material.css';

And here is my package.json

  "dependencies": {
    "@angular/material": "^2.0.0-beta.7",
    "angular": "^1.6.4",
    "angular-material": "^1.1.4",
    "angular-translate": "^2.15.1",
    "angular-translate-storage-cookie": "^2.15.1",
    "angular-translate-storage-local": "^2.15.1",
    "angular-ui-router": "^1.0.3",
    "jquery": "^3.2.1",
    "bootstrap": "^3.3.7",
    "bootstrap-select": "^1.12.3",
    "json-loader": "^0.5.4",
    "material-design-icons": "^3.0.1"
  },

But when I run my page it says:

bootstrap.js?f974:8 Uncaught Error: Bootstrap's JavaScript requires jQuery
    at eval (eval at <anonymous> (app.bundle.js:1094), <anonymous>:8:9)
    at Object.<anonymous> (app.bundle.js:1094)
    at __webpack_require__ (app.bundle.js:20)
10
  • import * as $ from 'jquery'; Or import * as $ from jquery/dist/jquery.min.js //Just looked into some starter projects, they mostly define it somehow like this. This is no answer just a hint what I found. Commented Jul 11, 2017 at 11:22
  • @Doomenik im definately gonna give that a try Commented Jul 11, 2017 at 11:46
  • Naaa, same result :-( The only way I can get this to work is if I include it directly in the HTML page - all the others import just fine, its only jquery that is the problem Commented Jul 11, 2017 at 11:49
  • I completly forgot to ask, do you use angular cli ? If yes add it in the angular-cli.json under scripts Commented Jul 11, 2017 at 12:33
  • 1
    eventually this one helps stackoverflow.com/questions/39063396/… same like stackoverflow.com/questions/41778884/… Commented Jul 12, 2017 at 4:28

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.