Ionic Firebase CRUD应用程序无法匹配任何路由

问题描述 投票:2回答:1

[OK BRAND]对Ionic开发来说是新的,我已经遵循了这个基本教程https://javebratt.com/crud-ionic-firestore/。但是在您转到详细信息页面的步骤4中,我收到此错误。

错误错误:未被捕获(承诺):错误:无法匹配任何路由。网址段:“ detail / rXubsrpxkszX7GsaS96r”

本教程很好,但是其中有很多陷阱,缺少一些东西,一直在绞尽脑汁,无法越过这个陷阱。我什至不十分确定此错误与哪些文件相关,但是这里......>

这是我的detail.page.ts

  import { Component, OnInit } from '@angular/core';
  import { ActivatedRoute } from '@angular/router';
  import { Note } from '../../models/note.interface';
  import { FirestoreService } from '../../services/data/firestore.service';
  import { Observable } from 'rxjs';

  @Component({
    selector: 'app-detail',
    templateUrl: './detail.page.html',
    styleUrls: ['./detail.page.scss'],
  })
  export class DetailPage implements OnInit {
    public note: Observable<Note>;
    constructor(
      private firestoreService: FirestoreService,
      private route: ActivatedRoute
    ) {}

    ngOnInit() {
      const noteId: string = this.route.snapshot.paramMap.get('id');
      this.note = this.firestoreService.getNoteDetail(noteId).valueChanges();
    }
  }

这是我在firestore.service.ts中使用的功能

getNoteDetail(noteId: string): AngularFirestoreDocument<Note> {
  return this.firestore.collection('noteList').doc(noteId);
}

在app-routing.module.ts中,我看到它被称为detail:id,但是在其他所有地方都是noteId,因此不确定那是正确的,但是添加noteId并没有帮助。

  import { NgModule } from '@angular/core';
  import { PreloadAllModules, RouterModule, Routes } from '@angular/router';

  const routes: Routes = [
    { path: '', redirectTo: 'home', pathMatch: 'full' },
    { path: 'home', loadChildren: () => import('./home/home.module').then( m => m.HomePageModule)},
    { path: 'create', loadChildren: './pages/create/create.module#CreatePageModule' },
    { path: 'detail:id', loadChildren: './pages/detail/detail.module#DetailPageModule' },
  ];

  @NgModule({
    imports: [
      RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
    ],
    exports: [RouterModule]
  })
  export class AppRoutingModule { }

我不知道在哪里追逐这个错误。任何帮助将不胜感激!

确定是Ionic开发的新品牌,我遵循了这个基本教程https://javebratt.com/crud-ionic-firestore/。但是在您转到详细信息页面的步骤4中,我收到此错误。错误...

angular ionic2 angularfire2
1个回答
0
投票

延迟了几个月,但希望它将对其他人有所帮助。因此,您在app-routing.module.ts

© www.soinside.com 2019 - 2024. All rights reserved.