不能去特定的路线

时间:2017-01-12 00:09:46

标签: angular firebase angular-cli

我在我的应用程序中做了一个简单的路由,并且在localhost上一切正常,但是当我在托管上载dist文件夹时,ng build我无法访问特定链接,当我在浏览器上输入它们时,为www.mydomain.com/login。我在app.module声明中导入routableComponents

APP-routing.module.ts

const routes: Routes = [
  {
    path: '',
    pathMatch: 'full',
    redirectTo: 'main/posts'
  },
  {
    path: 'main',
    component: MainComponent,
    children: [
      {
        path: 'posts',
        component: PostListComponent,

      },
      {
        path:'posts/watching',
        component: WatchingComponent
      },
      {
        path: 'posts/reading',
        component: ReadingComponent
      },
      {
        path: 'posts/brickets',
        component: BricketsComponent
      },

  },
  {
    path: 'login',
    component: LoginComponent
  }

];

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

export class AppRoutingModule {
}

export const routableComponents = [
  PostListComponent,
  LoginComponent,
  WatchingComponent,
  ReadingComponent,
  BricketsComponent,
  MainComponent
];

0 个答案:

没有答案