首页 > 解决方案 > 如何在 Angular 中添加页面刷新

问题描述

我尝试了以下代码。我想在点击游戏路线时添加页面自动刷新。因为当我移动到游戏页面数据没有自动刷新,直到页面重新加载

  <mat-list-item routerLink="{{routes.Gamecard}}" routerLinkActive="active">
    <mat-icon>games</mat-icon> GAMES
  </mat-list-item>

任何人都可以帮助我吗?

谢谢

标签: javascripthtmlangular-material

解决方案


To resolve this problem i know two ways:

  1. Try to use [href]="routes.Gamecard" instead routerLink="{{routes.Gamecard}}" routerLinkActive="active", this is the crutch, but, i think this can work.
  2. Create the refresh method in your game-page class, and try to set data in this method by click on your list item, if you are already on the game page.

Are you using ngOnInit interface? Maybe this is what you need


推荐阅读