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

157
Vistas
Angular component keeps refreshing on its own and I lose state

I have a view in which part of it loads another within using routing. Here is the part that loads another:

<a href="/productDetails/{{product.ProductId}}">{{product.Name}}</a>

And here is the div where I have my other component (productDetails) getting loaded:

<div class='col-md-6 body-content'>
    <router-outlet></router-outlet>
</div>

That works fine. But, whenever the component gets loaded, the hosting component refreshes itself and I lose its state. I don't know why this behaviour is happening because I coded the same app in AngularJS and it works as expected.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You should be using routeLink attribute instead of href

<a [routerLink]="['/productDetails', product.ProductId]">{{product.Name}}</a>

Update your route defintion as

{path: 'productDetails/:ProductId', component: ProductDetailsComponent
over 4 years ago · Santiago Trujillo 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