1

I'm using Bootstrap dropdown list to display whats in the list. First time using Bootstrap with Angular 4 and it doesnt work as it should. I got three items inside the "Varukorg" but it displays on eachother and not in line.

enter image description here

<li *ngIf="user.personId != 2">
  <div class="dropdown" style="color:gray;">
    <span class="glyphicon glyphicon-shopping-cart" style="color:antiquewhite; margin-top:15px;">
    </span>
     Varukorg
       <div class="numberCircle" *ngIf="count != 0">
         <h6 style="margin-top:-6px; margin-left:-3px;">{{count}}
         </h6>
       </div>
       <div>
         <ul class="dropdown-content" *ngFor="let items of list">
           <li style="margin-left:-10px;">
              {{items.name}} - {{items.price}}
           </li>
        </ul>
     </div>
   </div>
</li>

2 Answers 2

1

You're creating a new "ul" element for each item in your "list" variable. You should move the *ngFor directive onto the "li" element.

    <ul class="dropdown-content">
       <li style="margin-left:-10px;" *ngFor="let items of list">
          {{items.name}} - {{items.price}}
       </li>
    </ul>
Sign up to request clarification or add additional context in comments.

1 Comment

thanks :) I used this on another place and I didnt have any problem, but ill change it there too!
1

ngFor should be on the li element and remove the custom margin

<ul class="dropdown-content" >
           <li *ngFor="let items of list"">
              {{items.name}} - {{items.price}}
           </li>
</ul>

2 Comments

thanks :) I used this on another place and I didnt have any problem, but ill change it there too!
yeah ofc it did :)

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.