İki rotam var. :
- ev [ " ]
- hakkında ['hakkında']
Tarayıcımla doğrudan / hakkında bölümüne gittiğimde, 2 şey fark ettim :
- ev modülüm önceden yüklenmiş (oysa talep ettim /hakkında)
- URL bu gibi rewritted var : /hakkında - > / - > hakkında /
uygulama yönlendirme.modül.t
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
const routes: Routes = [
{ path: '', loadChildren: () => import('./routes/home/home.module').then(m => m.RoutesHomeModule) },
{ path: 'about', loadChildren: () => import('./routes/about/about.module').then(m => m.RoutesAboutModule) },
{ path: '**', redirectTo: '', pathMatch: 'full' }
];
@NgModule({
imports: [ RouterModule.forRoot(routes, { relativeLinkResolution: 'legacy' }) ],
exports: [ RouterModule ]
})
export class AppRoutingModule { }
uygulama.bileşen.TH
import { Component, OnInit } from '@angular/core';
import { NavigationStart, Router } from '@angular/router';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.less'],
})
export class AppComponent implements OnInit {
constructor(
private router: Router,
) { }
ngOnInit(): void {
this.router.events.subscribe(event => {
if (event instanceof NavigationStart) {
// outputs "/about" but NEVER "/"
console.log(event.url);
}
});
}
}
Açısal : 13.0.2
Krom : 96.0.4664.55
İşletim SİSTEMİ: macOS 12.0.1