1

I am trying to add a bootstrap menu to my angular 6 project. This is the code

  <ul class="nav nav-pills">
  <li class="nav-item">
    <a class="nav-link active" href="#">User</a>
  </li>
  <li class="nav-item dropdown">
    <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#">Customer</a>
    <div class="dropdown-menu">
      <a class="dropdown-item" href="#">OL User</a>
    </div>
  </li>

</ul>

The issue is, when I click customer link, URL redirect to the localhost:4200/# and submenu is not opening. below code techniques, I used to project:

app.component.ts

import {HashLocationStrategy, LocationStrategy} from '@angular/common';

app.routing.module.ts

@NgModule({
  imports: [RouterModule.forRoot(routes,{useHash: true})],
  exports: [RouterModule],

})
1
  • 1
    tagged angularjs but is asking about angular - should be editted Commented Nov 2, 2018 at 8:42

1 Answer 1

2

Local redirects in Angular are usually done by using routerLink:

From the DOCS

<a [routerLink]="['/user/bob']" [queryParams]="{debug: true}" queryParamsHandling="merge">
  link to user component
</a>

More information about Angular routing


You can use href if you want. But the biggest issue is that you haven't associated a component with a route.

Take a look at this example

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.