2

I want to create multilevel dropdwon using bootstrap 4 and angular 7.

I could create simple dropdown in navbar using the official documentation of bootstrap.

But when i tried to create multilevel dropdown, it wont working.

Bootstrap 4: Multilevel Dropdown Inside Navigation

using the above link , I could find a solution to make multilevel dropdown.

But it uses some kind of jQuery code for working fine.

Is there any built in method for making multilevel dropdown using bootstrap?

I didn't see anything related to this in official documentation of bootstrap .

I don't know whether I missed any scripts or css in my code.

"styles": [
                            "node_modules/bootstrap/dist/css/bootstrap.min.css",
                            "src/styles.css"

                        ],
                        "scripts": [
                            "node_modules/jquery/dist/jquery.min.js",
                            "node_modules/bootstrap/dist/js/bootstrap.min.js",
                            "node_modules/popper.js/dist/popper.min.js"
                        ],


here is my angular.json part for bootstrap css and js.

any kind of Solution will be thankful.

enter image description here

I need the result something like this

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
ADARSH K
  • 606
  • 1
  • 8
  • 21
  • This may be helpful with jQuery. https://stackoverflow.com/a/45755948/8440216 – Neenu Chandran Jun 04 '20 at 08:45
  • Check if this answer can help you: https://stackoverflow.com/questions/61271254/how-to-create-a-submenu-in-a-dynamic-dropdown-list-with-typescript-and-angular/61745893#61745893 – Luciano Jun 04 '20 at 08:45
  • for every collapse method or dropdown bootstrap is using jQuery. Otherwise it wont work – Dariun Jun 04 '20 at 08:52
  • @NeenuChandran I alreaddy checked this , and its working fine as i told.But the problem is,I am not a fan of using JqQuery.So I am asking whether there is built in methods for doing this. – ADARSH K Jun 04 '20 at 10:20
  • @Dariun https://www.youtube.com/watch?v=jEAeDID1pks I checked this video and did exact like that. but the result wasn't like expected. – ADARSH K Jun 04 '20 at 10:24

1 Answers1

0

Try with this:

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>

<div class="container">
    <div class="row">
        <h2>Multi level dropdown menu in Bootstrap 3</h2>
        <hr>
        <div class="dropdown">
            <a id="dLabel" role="button" data-toggle="dropdown" class="btn btn-primary" data-target="#" href="/page.html">
                Dropdown <span class="caret"></span>
            </a>
            <ul class="dropdown-menu multi-level" role="menu" aria-labelledby="dropdownMenu">
              <li><a href="#">Some action</a></li>
              <li><a href="#">Some other action</a></li>
              <li class="divider"></li>
              <li class="dropdown-submenu">
                <a tabindex="-1" href="#">Hover me for more options</a>
                <ul class="dropdown-menu">
                  <li><a tabindex="-1" href="#">Second level</a></li>
                  <li class="dropdown-submenu">
                    <a href="#">Even More..</a>
                    <ul class="dropdown-menu">
                        <li><a href="#">3rd level</a></li>
                        <li><a href="#">3rd level</a></li>
                    </ul>
                  </li>
                  <li><a href="#">Second level</a></li>
                  <li><a href="#">Second level</a></li>
                </ul>
              </li>
            </ul>
        </div>
    </div>
</div>

See Reference: https://bootsnipp.com/snippets/kM4Q

Neenu Chandran
  • 722
  • 1
  • 6
  • 18
  • You are really a life saver.Thanks for the Solution. The solution is for Bootstrap 3 .Bootstrap 4 is very different from 3. https://codepen.io/svnt/pen/beEgre Guys, Follow this link for Bootstrap 4 solution. – ADARSH K Jun 04 '20 at 11:57