我正在创建一个默认路由器为登录组件的应用程序,当用户点击相关路径时,它会从登录组件进一步发展。
我的 app.module.ts 文件看起来像这样
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { GuessComponent } from './guess/guess.component';
import { HttpModule } from '@angular/http';
import { RouterModule } from '@angular/router';
import { FormsModule } from '@angular/forms';
import { SignupComponent } from './signup/signup.component';
import { MainComponent } from './main/main.component';
@NgModule({
declarations: [
AppComponent,
GuessComponent,
SignupComponent,
MainComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
RouterModule.forRoot([
{
path: '',
redirectTo: "/login",
pathMatch: 'full'
},
{ path: 'login', component: GuessComponent },
{
path: 'signup',
component: SignupComponent
},
{
path: 'main',
component: MainComponent
}
])
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
我在 app.component.html
中添加了<router-outlet></router-outlet>
我的代码出了什么问题,因为当我运行应用时,它没有显示任何内容。