Ich habe Probleme, mein aktuelles Problem zu verstehen, wo ich die neue Seite nicht laden kann, wenn auf routerlink
geklickt wird.Angular 2 Routing findet keine Routen
Ich habe viele verschiedene Strukturen für den Link versucht, aber egal was ich es zu dem Fehler in der Konsole ändern, sagt
VM39436:48 EXCEPTION: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'stream'
ich Vorlage Layout bin dann meine Seiten Kinder dieser Layouts zu machen. Ein Layout ist sicher und ein Layout ist öffentlich.
In app.routing.ts
const APP_ROUTES: Routes = [
{
path: '',
redirectTo: 'stream',
pathMatch: 'full',
},
{
path: 'profile',
component: SecureLayoutComponent,
data: {
title: 'Secure Views'
},
children: [
{
path: 'Profile',
loadChildren: 'profile/profile.module#ProfileModule'
}
]
},
{
path: '',
component: PublicLayoutComponent,
data: {
title: 'Public Views'
},
children: [
{
path: 'stream',
loadChildren: 'stream/stream.module#StreamModule',
}
]
}
];
Jetzt habe ich einen Ordner für Profil und einen Ordner für Strom.
so, wenn Sie streamen Verzeichnis zu verschieben, ist dies der Strom-routing.module.ts
import { NgModule } from '@angular/core';
import { Routes,
RouterModule } from '@angular/router';
import { StreamComponent } from './stream.component';
const routes: Routes = [
{
path: '',
component: StreamComponent,
data: {
title: 'Stream'
}
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class StreamRoutingModule {}
und das ist die Profil-routing.module.ts
import { NgModule } from '@angular/core';
import { Routes,
RouterModule } from '@angular/router';
import { ProfileComponent } from './profile.component';
export const routes: Routes = [
{
path: '',
data: {
title: 'Secure Pages'
},
children: [
{
path: 'profile',
component: ProfileComponent,
data: {
title: 'Profile Page'
}
}
]
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class ProfileRoutingModule {}
Also diese lädt fein wenn die App rendert. Aber wenn ich versuche zu klicken,
<a class="nav-link" routerLinkActive="active" [routerLink]="['../profile/profile']">Profile</a>
Oder
<a class="nav-link" routerLinkActive="active" [routerLink]="['../profile']">Profile</a>
oder
<a class="nav-link" routerLinkActive="active" [routerLink]="['/profile']">Profile</a>
ich den Fehler oben erwähnt erhalten,
So aus dem /
Verzeichnis
/stream/stream.component.ts
& stream-routing.module.ts
/profile/profile.component.ts
& profile-routing.module.ts
// Kann dies nicht aus dem öffentlichen Layout zugreifen.
Ich sehe keine Routen mit 'Pfad: 'Stream'' in ihnen – bassxzero
Schauen Sie in app.routing und im Stream-Routing.Module es funktioniert gut. Es ist der Profilrouter, an den ich nicht arbeiten kann. Aber wenn der Stream als Hauptseite geladen wird und ich auf den Link klicke, um zur Profilroute zu gelangen, wird der Stream erwähnt. Es hat mich wirklich verwirrt. Ich stehe seit gestern auf diesem Thema, weshalb ich um Hilfe gebeten habe. Ich bin auf diesem einen so verloren. – wuno
Sie haben 2 Routen mit Pfad '''' (die erste Weiterleitungsroute und 'PublicLayoutComponent'). Was ist der Zweck? –