Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

132
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda