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

117
Views
Actualizar la página después de cambiar la URL

Parece ser algo básico, pero estoy luchando. Tengo una vista "/plugin/{pluginId}" que no se actualiza cuando presiono enter después de cambiar el pluginId en la barra de direcciones. Tengo que actualizar manualmente la página en el navegador. ¿Qué puedo hacer para que se actualice automáticamente?

 <div> <div> <a mat-raised-button href="/plugin"> <span>&#8592;</span> </a> <a mat-raised-button href="" style="float: right">Send message</a> </div> <div> <ul> <li *ngFor="let message of (messages$ | async)"> {{message.message}} <br><br> </li></ul> </div> </div>
 export class Foo implements OnInit { pluginMessagesState$: Observable< fromPluginMessages.State >; pluginId = ''; messages$: Observable< Message[] >; constructor(private route: ActivatedRoute, private store: Store< fromRoot.State >, ) { if ( this.route.snapshot.params[ 'pluginId' ] ) { this.pluginId = this.route.snapshot.params[ 'pluginId' ]; } this.pluginMessagesState$ = this.store.select( fromRoot.getPluginMessagesState ); this.messages$ = this.pluginMessagesState$.pipe( map( state => state.pluginMessages.get( this.pluginId )?.list || [] ) ); } ngOnInit(): void { } }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

import { ActivatedRoute } from '@angular/router'; @Component({ selector: 'app-user-detail', templateUrl: 'user-detail.component.html' }) export class UserDetailComponent implements OnInit { constructor(private activeRoute: ActivatedRoute) { } ngOnInit() { const queryParams = this.activeRoute.snapshot.queryParams const routeParams = this.activeRoute.snapshot.params; // do something with the parameters this.loadUserDetail(routeParams.id); } }

o

 ngOnInit() { this.activeRoute.queryParams.subscribe(queryParams => { // do something with the query params }); this.activeRoute.params.subscribe(routeParams => { this.loadUserDetail(routeParams.id); }); }
about 4 years ago · Juan Pablo Isaza Report

0

¿El archivo de su enrutador se ve así?

 {path: 'plugin/:id', component: UserDetailComponent}

Si es así, suscríbase a ActivatedRoute (inyéctelo en los parámetros del constructor) así:

 public pluginId: number; constructor(private route: ActivatedRoute) { }

Y acceda al parámetro suscribiéndose a route.params:

 ngOnInit() { this.routeSub = this.route.params.subscribe(params => { // update the pluginId accordingly this.pluginId = params['id']; }); }
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!