角度,链接已更改,但页面没有加载

发布于 2025-01-30 18:01:12 字数 1967 浏览 1 评论 0原文

当我单击 skip 时,我想转到下一个单词,但是当我单击 skip 时,链接更改了,但是下一个单词并未出现在旧单词中,并且控制台中没有错误消息。这是 skip 按钮的代码:

next() {
  this.lessonService.getNextLessonElement(this.elementId).subscribe({
    next: response => {
      console.log('go to level')
      console.log('/level/'+this.lessonId+'/'+response.id)
      this.router.navigate(['/level/'+this.lessonId+'/'+response.id]);

      // this.router.navigate(['level']);
    }
    , error: (err: AppError) => {
      if (err instanceof NotFoundError) {
        console.log(err)
      }
    }
  })
}
<div class="flex-column flex-center">
      <div class="block">
        <h2 class="title">Try to repeat this word:</h2>
      </div>
      <div class="flex-row">
        <h3 class="sentence">{{ element.element }}</h3>
        <i
          class="fa fa-volume-off fa-3x block micro"
          (click)="textToSpeech(element.element || 'undefined')"
        ></i>
      </div>
      <div *ngIf="!recording" (click)="startRecording()" class="mic">
        <i class="fa fa-microphone fa-5x micro" aria-hidden="true"></i>
        Start Recording
      </div>
      <div *ngIf="recording" (click)="stopRecording()" class="mic">
        <i
          class="fa fa-microphone fa-5x"
          aria-hidden="true"
          style="color: red"
        ></i>
        <div style="color: red">Stop Recording</div>
      </div>
      <audio controls="" *ngIf="url">
        <source [src]="sanitize(url)" type="audio/wav" />
      </audio>
    </div>

<button mat-flat-button color="warn" (click)="next()">Skip</button>
const routes: Routes = [
  path: 'level', component: LevelComponent },
  path: 'level/:lessonid/:elementid', component: LevelComponent },
];

I want to go to the next word when I click Skip, but when I click Skip the link changed but the next word doesn't appear in place of the old word, and there are no error messages in the console. This is the code for the Skip button:

next() {
  this.lessonService.getNextLessonElement(this.elementId).subscribe({
    next: response => {
      console.log('go to level')
      console.log('/level/'+this.lessonId+'/'+response.id)
      this.router.navigate(['/level/'+this.lessonId+'/'+response.id]);

      // this.router.navigate(['level']);
    }
    , error: (err: AppError) => {
      if (err instanceof NotFoundError) {
        console.log(err)
      }
    }
  })
}
<div class="flex-column flex-center">
      <div class="block">
        <h2 class="title">Try to repeat this word:</h2>
      </div>
      <div class="flex-row">
        <h3 class="sentence">{{ element.element }}</h3>
        <i
          class="fa fa-volume-off fa-3x block micro"
          (click)="textToSpeech(element.element || 'undefined')"
        ></i>
      </div>
      <div *ngIf="!recording" (click)="startRecording()" class="mic">
        <i class="fa fa-microphone fa-5x micro" aria-hidden="true"></i>
        Start Recording
      </div>
      <div *ngIf="recording" (click)="stopRecording()" class="mic">
        <i
          class="fa fa-microphone fa-5x"
          aria-hidden="true"
          style="color: red"
        ></i>
        <div style="color: red">Stop Recording</div>
      </div>
      <audio controls="" *ngIf="url">
        <source [src]="sanitize(url)" type="audio/wav" />
      </audio>
    </div>

<button mat-flat-button color="warn" (click)="next()">Skip</button>
const routes: Routes = [
  path: 'level', component: LevelComponent },
  path: 'level/:lessonid/:elementid', component: LevelComponent },
];

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文