1

I'm trying to learn Angular using bootstrap, but I have a problem concerning bootstrap dropdown element. It doesn't work at all. I've read through all the bugfixes I could find on Stack Overflow but none fixed my issue.

the concerned part of html :

        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
            Events
          </a>
          <div class="dropdown-menu" aria-labelledby="navbarDropdown">
            <a class="dropdown-item" href="#">Angular Connect</a>
          </div>
        </li>

concerned part of angular.json

            "styles": [
              "node_modules/bootstrap/dist/css/bootstrap.min.css",
              "src/styles.css"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "node_modules/popper.js/dist/umd/popper.min.js",
              "node_modules/bootstrap/dist/js/bootstrap.min.js"
            ]
  • I've already checked and all files are in the right directory
  • I've added popper.js to test a solution but it doesn't change anything

WORKAROUND SOLUTION : Add link for js, jquery AND css in index.html :

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>NgFundamentals</title>
  <base href="/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body class="container">
  <events-app></events-app>

  <script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</body>
</html>

However, this isn't perfect since it's not using the package manager. Just a temporary solution.

I don't know if anything else is of interest. Thanks already !

6
  • 1
    can you try to put them inside index.html ? Commented Jun 10, 2020 at 7:51
  • Is only the dropdown not working or can you not use bootstrap styles at all? Commented Jun 10, 2020 at 7:53
  • The bootstrap styles are working. I've tried to add it in the index.html it doesn't seems to work (gonna edit my post above) Commented Jun 10, 2020 at 7:56
  • 1
    I can't see bootsrap css in index.html Commented Jun 10, 2020 at 8:26
  • Since bootstrap styles worked i didn't think it was necessary but it worked ! thanks a lot ! (Can you post your solution as an answer so I can mark this subject as resolved ?) Commented Jun 10, 2020 at 8:34

1 Answer 1

3

You said but i think your false directory.Must be like this

"styles": [
  "../node_modules/bootstrap/dist/css/bootstrap.min.css",
   "scss/style.scss"
],
"scripts": [
  "../node_modules/jquery/dist/jquery.slim.js"
],
enter code here

There must be two dot in front ot the node_modules. İf you wanna sure.Please click the file and drag drop index.html.You will see truth directory.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your response ^^ I've tried it and it changes nothing :/.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.