简体   繁体   English

使用 routerLink 时,我的 angular 组件未更新

[英]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 }} .我有以下问题:当我使用<a href="conceptos/edit-conceptos/{{ concepto.id}}">标记修改 edit-conceptos 组件中的字段并返回到 list-conceptos 组件时,更改已反映,但routerLink="../edit-conceptos/{{ concepto.id }}不会发生这种情况。

I am consuming both the list service and the update service with apollo-client.我正在使用 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"注意:看一下图片中的拼写错误"list-concetos" ,而不是 "list-conceptos"

The routerLink equivalent of href in your case would be:在您的情况下,与href等效的routerLink将是:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用routerLink角6-7时组件未获得contentChildren - Component doesn't get contentChildren when using routerLink angular 6-7 单击 routerLink 时 Angular 未重新加载组件 - Angular is not Reloading component when routerLink clicked Angular 2 - 再次单击routerLink时重新加载组件 - Angular 2 - Reload component when routerLink clicked again Angular 2使用组件属性动态设置routerLink - Angular 2 dynamically set routerLink using a component property 如何将 Storybook 与使用 [routerLink] (Angular) 的组件一起使用? - How to use Storybook with a component using [routerLink] (Angular)? Angular-使用routerLink在父组件上获取事件 - Angular - Get Event on Parent Component using routerLink 在Angular 2+中,我可以检测到何时将指令(如routerLink)应用于我的自定义组件吗? - In Angular 2+, can I detect when a directive (like routerLink) is applied to my custom component? 当 routerLink 到其他组件时,Angular 路由器也会加载先前的组件 - Angular router loads previous component as well when routerLink to other component 在Angular中使用RouterLink导航时保持状态 - Keep state when navating using RouterLink in Angular Angular中使用routerLink时如何处理异常 - How to handle exceptions when using routerLink in Angular
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM