角按钮路由错误

发布于 2025-02-09 20:19:30 字数 1096 浏览 0 评论 0原文

在我的Angular应用程序中,我有一个带有按钮列表的垫子卡组件。如下所示:

<mat-card class="side-card">
    <mat-card-title>Images</mat-card-title>
    <mat-card-subtitle>Choose to start explanation</mat-card-subtitle>
    <p></p>
    <mat-divider inset></mat-divider>
    <p></p>
    <mat-card-content [style.overflow]="'auto'" [style.height.px]="'720'">
        <mat-selection-list #image [multiple]="false">
            <mat-list-option class="list" *ngFor="let image of images" [value]="image">
              <button [routerLink]="['/images', image._id]" routerLinkActive="active" class="transparent-button">{{image.imagePath.split("/").slice(-1)}}</button>
            </mat-list-option>
          </mat-selection-list>
    </mat-card-content>
</mat-card>

我在这里遇到了两个问题:

  1. 如果我在加载按钮路由后直接单击按钮不起作用。我需要等待片刻,直到可以单击带有成功路由的按钮。
  2. 我已经单击一个按钮并将其重定向到 /images /id之后,我无法单击任何成功重定向到另一个ID的按钮。这意味着在浏览器URL中,我可以看到不同的ID,但是它没有加载其页面。

有人知道这一点并可以帮助我吗?这将非常有帮助,谢谢您。

in my angular app I have a mat-card component with a list of buttons. Code as followed:

<mat-card class="side-card">
    <mat-card-title>Images</mat-card-title>
    <mat-card-subtitle>Choose to start explanation</mat-card-subtitle>
    <p></p>
    <mat-divider inset></mat-divider>
    <p></p>
    <mat-card-content [style.overflow]="'auto'" [style.height.px]="'720'">
        <mat-selection-list #image [multiple]="false">
            <mat-list-option class="list" *ngFor="let image of images" [value]="image">
              <button [routerLink]="['/images', image._id]" routerLinkActive="active" class="transparent-button">{{image.imagePath.split("/").slice(-1)}}</button>
            </mat-list-option>
          </mat-selection-list>
    </mat-card-content>
</mat-card>

I got two problems here:

  1. If I click on a button directly after they loaded the button routing is not working. I need to wait a few moments until I can click on a button with a successful routing.
  2. After I already clicked on a button and it redirected me to /images/id, I cannot click on any button with a successful redirecting to another id. That means in the browser url I can see the different id, but it´s not loading the page of it.

Does anyone know anything about this and can help me? That would be very helpful, thank you in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冰之心 2025-02-16 20:19:31

对于第二个问题,您必须订阅激活的路由 - 参数属性才能通知到路线的变化。

For your second problem you have to subscribe to the activated route - params property to get notified to the changes in the route.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文