在浏览器URL上键入时,应用未重定向到“邀请用户页面”

时间:2019-07-19 08:09:45

标签: angular angular-router

我正在尝试通过输入以下路由invite-user从浏览器URL访问我的localhost:4200/invite-user路由,但是应用程序将我重定向到登录页面

import { NgModule } from "@angular/core";
import { Routes, RouterModule } from "@angular/router";

import { LoginComponent } from "src/app/components/login/login.component";
import { RegisterComponent } from "src/app/components/register/register.component";
import { InviteUserComponent } from "src/app/components/invite-user/invite-user.component";

const routes: Routes = [
  { path: "login", component: LoginComponent },
  { path: "register-user", component: RegisterComponent },
  { path: "invite-user", component: InviteUserComponent },
  { path: "", redirectTo: '/login', pathMatch: 'full' }
];

@NgModule({
  declarations: [],
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AuthRoutingModule {}

1 个答案:

答案 0 :(得分:0)

像这样更改订单

const routes: Routes = [
  { path: "", redirectTo: '/login', pathMatch: 'full' },
  { path: "login", component: LoginComponent },
  { path: "register-user", component: RegisterComponent },
  { path: "invite-user", component: InviteUserComponent }
];