从一页导航到另一页时出现错误。我收到的错误是未捕获的(承诺中):错误:无法匹配任何路由。 URL段:'EventCreatePage'
我在下面发布了.ts文件
我想从主页转到eventCreatePage
这是routing.module.ts
import { NgModule } from '@angular/core';
import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
import { AuthGuard } from './services/user/auth.guard';
const routes: Routes = [
{ path: '', redirectTo: 'signup', pathMatch: 'full' },
{ path: 'home', loadChildren: './home/home.module#HomePageModule',canActivate: [AuthGuard], },
{ path: 'event-create/:id', loadChildren: './pages/event-create/event-create.module#EventCreatePageModule' ,canActivate: [AuthGuard],},
{ path: 'event-detail/:id', loadChildren: './pages/event-detail/event-detail.module#EventDetailPageModule',canActivate: [AuthGuard], },
{ path: 'event-list', loadChildren: './pages/event-list/event-list.module#EventListPageModule' },
{ path: 'login', loadChildren: './pages/login/login.module#LoginPageModule' },
{ path: 'profile', loadChildren: './pages/profile/profile.module#ProfilePageModule' },
{ path: 'reset-password', loadChildren: './pages/reset-password/reset-password.module#ResetPasswordPageModule' },
{ path: 'signup', loadChildren: './pages/signup/signup.module#SignupPageModule' },
];
@NgModule({
imports: [
RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
],
exports: [RouterModule]
})
export class AppRoutingModule { }
这是我的Home.page.ts
import { Component } from '@angular/core';
import { Injectable } from '@angular/core';
import { AngularFireList, AngularFireDatabase } from 'angularfire2/database';
import { Quiz } from '../services/event/quiz.interface';
import { EventCreatePage } from '../pages/event-create/event-create.page'
import { Router } from '@angular/router';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage {
quiz= {} as Quiz;
eventcreatePage = EventCreatePage;
quiz$ : AngularFireList<Quiz>;
constructor(private database : AngularFireDatabase,private router: Router){}
onclick(quiz: Quiz){
this.router.navigate(['EventCreatePage']);
}
}
这是我的home.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { IonicModule } from '@ionic/angular';
import { FormsModule } from '@angular/forms';
import { RouterModule, Routes } from '@angular/router';
import { HomePage } from './home.page';
import { EventCreatePage } from '../pages/event-create/event-create.page';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
RouterModule.forChild([
{
path: '',
component: HomePage
},
])
],
declarations: [HomePage]
})
export class HomePageModule {}