簡體   English   中英

使用 routerLink 時,我的 angular 組件未更新

[英]My angular component is not updated when using routerLink

我有以下問題:當我使用<a href="conceptos/edit-conceptos/{{ concepto.id}}">標記修改 edit-conceptos 組件中的字段並返回到 list-conceptos 組件時,更改已反映,但routerLink="../edit-conceptos/{{ concepto.id }}不會發生這種情況。

我正在使用 apollo-client 使用列表服務和更新服務。

以下組件負責列出

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

在此處輸入圖像描述

謝謝你

以這種方式嘗試:

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

注意:看一下圖片中的拼寫錯誤"list-concetos" ,而不是 "list-conceptos"

在您的情況下,與href等效的routerLink將是:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM