角按钮路由错误
在我的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>
我在这里遇到了两个问题:
- 如果我在加载按钮路由后直接单击按钮不起作用。我需要等待片刻,直到可以单击带有成功路由的按钮。
- 我已经单击一个按钮并将其重定向到 /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:
- 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.
- 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于第二个问题,您必须订阅激活的路由 - 参数属性才能通知到路线的变化。
For your second problem you have to subscribe to the activated route - params property to get notified to the changes in the route.