0

I want to use ng-bootstrap in my dropdown but it's not working. I have imported NgbModule in app.module.ts. I have attached images below .

<nav class="navbar navbar-expand-md navbar-light bg-light fixed-top">

Organic Shop

<ul class="navbar-nav mr-auto">
  <li class="nav-item active">
    <a class="nav-link" routerLink="/">Home <span class="sr-only">(current)</span></a>
  </li>
  <li class="nav-item">
    <a class="nav-link" routerLink="/shopping-cart">Shopping Cart</a>
  </li>
  <li ngbDropDown class="nav-item dropdown">
    <a ngbDropdownToggle class="nav-link dropdown-toggle"  id="dropdown01" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Username</a>
    <div ngbDropdownMenu class="dropdown-menu" aria-labelledby="dropdown01">
      <a class="dropdown-item" routerLink="/my/orders">My Orders</a>
      <a class="dropdown-item" routerLink="/admin/orders">Manage Orders</a>
      <a class="dropdown-item" routerLink="/admin/products">Manage Products</a>
      <a class="dropdown-item" routerLink="">Log Out</a>
    </div>

  </li> 

Output after the above code

4
  • it would be better if you paste the code than image Commented Feb 22, 2018 at 9:03
  • done pasting code. Commented Feb 22, 2018 at 9:05
  • What’s not working ? Do you receive error messages ? Commented Feb 22, 2018 at 9:06
  • 1
    No error messages Commented Feb 22, 2018 at 9:08

1 Answer 1

3

In your Module, add ngbmodule as root and also add it to providers.

import { NgbModule, NgbActiveModal } from "@ng-bootstrap/ng-bootstrap";


   imports: [    
        NgbModule.forRoot(),
    ],
   providers: [NgbActiveModal],
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.