Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
Angular - How to prevent <a href="#"> on the Nav header dropdown from redirecting to Home Page

In my Angular-13 project, when a user successfully logs in he's redirected to the dashboard. Then on the dashboard Nav header the user can signout:

header.component.ts:

signOut() {
 this.router.navigate(['/auth'])
}

header.component.html:

<li class="nav-item dropdown user-menu">
  <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown">
    <img src="assets/img/user2-160x160.jpg" class="user-image img-circle elevation-2" alt="User Image">
    <span class="d-none d-md-inline">Alexander Pierce</span>
  </a>
  <ul class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
    <!-- User image -->
    <li class="user-header bg-primary">
      <img src="assets/img/user2-160x160.jpg" class="img-circle elevation-2" alt="User Image">
    </li>
    <!-- Menu Footer-->
    <li class="user-footer">
      <a href="#" class="btn btn-default btn-flat">Profile</a>
      <a class="btn btn-danger btn-flat float-right" (click)="signOut()">Sign out</a>
    </li>
  </ul>
</li>

I expect that when I click on nav-item dropdown user-menu, it should dropdown and display signout. Then the user should be able to signout.

Instead of the it redirects to the home page.

When I changed # to javascript: void(0); the dropdown did not respond.

How do I resolve this?

Thanks

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you want to load the same page again you can use period instead of #,

 <a href="." class="btn btn-default btn-flat">Profile</a>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!