我有这段代码:
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AuthRegComponent } from './Components/Auth_Reg/Auth_Reg.component';
import { FirstSetupComponent } from './Components/First_Setup/First_Setup.component';
const appRoutes: Routes = [
{ path: 'setup', component: FirstSetupComponent },
{
path: '',
redirectTo: 'home',
pathMatch: 'full'
},
{
path: 'home',
component: AuthRegComponent
},
];
@NgModule({
imports: [
RouterModule.forRoot(appRoutes, { enableTracing: true })
],
exports: [
RouterModule
],
providers: [
]
})
export class AppRoutingModule { }
路径“”和主页 wor。如果我尝试/设置,我会看到AuthReg
组件。但是应该显示FirstSetupComponent
组件。如果FirstSetupComponent
组件的编号被替换。我仍然会再次看到AuthRegComponent
。
我的app.module代码:
import { HttpClientModule } from '@angular/common/http';
import { HttpModule } from '@angular/http';
import { RouterModule, Routes } from '@angular/router';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AuthRegComponent } from './Components/Auth_Reg/Auth_Reg.component';
import { FirstSetupComponent } from './Components/First_Setup/First_Setup.component';
import { TestService } from './Services/service.test';
@NgModule({
declarations: [
AuthRegComponent,
FirstSetupComponent,
],
imports: [
BrowserModule, HttpClientModule, HttpModule, AppRoutingModule
],
providers: [
TestService],
bootstrap: [AuthRegComponent]
})
export class AppModule { }
答案 0 :(得分:0)
您可以查看以下内容
您应尝试访问以下路线
<a [routerLink]="['/user/dummy']">
link to user component
</a>
如果您已完成上述2,请正确检查控制台