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

297
Views
¿Cómo actualizar/actualizar un 'estado' de Angular Router?

Estoy tratando de pasar datos de una página a otra con enrutamiento angular. Funciona perfectamente bien al ingresar a la página "siguiente" por primera vez. Sin embargo, al regresar a la página de inicio y presionar otro elemento, el state del enrutador no se actualizará. Continuará mostrando valores desde la primera vez que se hizo clic en un elemento.

¿Alguien tiene una idea de cómo hacer que funcione?

Ya probé varias cosas, por ejemplo, restablecer todos los valores "manualmente":

 pageBack() { this.router.navigate(['tabs/homepage'], { state: { 'space': undefined } }); this.space = {}; this.userId = ''; this.spaceId = ''; this.spaceName = ''; }

Aquí está el código:

inicio.pagina.html

 <div *ngIf="spaces"> <ion-item-sliding *ngFor="let space of spaces | async;"> <ion-item (click)="openspacedetailsPage(space)" detail> <ion-icon name="ellipse-outline" start></ion-icon> <ion-label> &nbsp; {{ space.spaceName }} </ion-label> </ion-item> </ion-item-sliding> </div>

home.page.ts

 openspacedetailsPage(space) { this.router.navigate(['tabs/space-details'], { state: { 'space': space } }); }

espacio-detalles.page.html

 <ion-header> <ion-toolbar> <ion-buttons slot="start"> <ion-back-button defaultHref="tabs/activities" (click)="pageBack()"></ion-back-button> </ion-buttons> <ion-title>{{ spaceName }}</ion-title> </ion-toolbar> </ion-header>

espacio-detalles.page.ts

 pageBack() { this.router.navigate(['tabs/homepage'], { state: { 'space': undefined } }); this.space = {}; this.userId = ''; this.spaceId = ''; this.spaceName = ''; }
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

En este caso, debe usar Angular EventEmitter.

Puedes comprobar esta respuesta. ¿Cuál es el uso adecuado de un EventEmitter?

over 4 years ago · Santiago Trujillo Report

0

Resolví con un enfoque ligeramente diferente usando un servicio de datos para pasar valores entre páginas:¿Cómo pasar objetos entre páginas en Angular?

over 4 years ago · Santiago Trujillo 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!