1

I have this html that is supposed to be a dropdown inside another dropdown. The hierarchy is:

Dropdown
  |_ First Dropdown
  |     |_ aaa
  |     |_ bbb
  |     |_ ccc
  |_ Second Dropdown
        |_ ddd

They look fine, but when I press on First Dropdown, the dropdown with values aaa, bbb, ccc won't show up. Same with Second Dropdown.

<div class="btn-group">
  <a class="btn dropdown-toggle" data-toggle="dropdown">
    Dropdown
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu">
    <li>
      <div class="btn-group dropright">
        <a class="btn dropdown-toggle" data-toggle="dropdown">
          First Dropdown
          <span class="caret"></span>
        </a>
        <ul class="dropdown-menu">
          <li>aaa</li>
          <hr>
          <li>bbb</li>
          <hr>
          <li>ccc</li>
        </ul>
      </div>
    </li>
    <hr>
    <li>
      <div class="btn-group dropright">
        <a class="btn dropdown-toggle" data-toggle="dropdown">
          Second Dropdown
          <span class="caret"></span>
        </a>
        <ul class="dropdown-menu">
          <li>ddd</li>
        </ul>
      </div>
    </li>
  </ul>
</div>

Which seems to be the problem? Thank you for your time!

5
  • How is this related with angular? I just see bootstrap classes in your html Commented Nov 23, 2018 at 8:52
  • I wanted to make sure in case somebody will give me a solution, it won't use javascript. Commented Nov 23, 2018 at 8:54
  • I am struggling to understand the purpose of this: so you have two dropdown inside one? can't you have two and populate the second from the first? Commented Nov 23, 2018 at 8:56
  • 2
    Please use HTML <optgroup> Tag w3schools.com/tags/tryit.asp?filename=tryhtml_optgroup Commented Nov 23, 2018 at 9:00
  • Inside First Dropdown and Second Dropdown I will have many values, I don't want them all to be visible.. Commented Nov 23, 2018 at 9:04

1 Answer 1

1

So you can kinda achieve this with angular material mat-select

you have <mat-select> there wich is a kinda dropdown menu and <mat-option> wich is an entry in a mat-select

however you can use a mat select inside of a mat option wich itself is a dropdown inside a dropdown.

<mat-select>entry
 <mat-option>hu
  <mat-select>
   <mat-option>hallo</mat-option>
  </mat-select>
 </mat-option>
 <mat-option>hi
  <mat-select>hello
   <mat-option>hallo</mat-option>
  </mat-select>
 </mat-option>
 <mat-option>hui
  <mat-select>
   <mat-option>hallo</mat-option>
  </mat-select>
 </mat-option>
</mat-select>
Sign up to request clarification or add additional context in comments.

Comments

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.