简体   繁体   中英

My angular component is not updated when using routerLink

I have the following problem: when I modify a field in the edit-conceptos component with the <a href="conceptos/edit-conceptos/{{ concepto.id}}"> tag and return to the list-conceptos component, the changes are reflected, but this does not happen with routerLink="../edit-conceptos/{{ concepto.id }} .

I am consuming both the list service and the update service with apollo-client.

the following component takes care of listing

ngOnInit(): void {
this.conceptoService.getConceptos().
subscribe(
  (res) => {
    this.conceptos = [...res];
  }
  (err) => {
    console.log(err)
  }
)}

enter image description here

thank you

Try in this way:

<a [routerLink]="[‘/edit-conceptos’, concepto.id]">

NOTE: Take a look of the typo in your image "list-concetos" , instead "list-conceptos"

The routerLink equivalent of href in your case would be:

[routerLink]="['edit-conceptos', concepto.id]"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM