部署Angular 2应用程序时路由出错

时间:2017-04-02 15:50:05

标签: angular

我收到此错误:

Error: Not Found
at C:\Users\George\Desktop\EXPRESS SERVER LIVE\myapp\app.js:30:13
at Layer.handle [as handle_request] (C:\Users\George\Desktop\EXPRESS SERVER LIVE\myapp\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (C:\Users\George\Desktop\EXPRESS SERVER LIVE\myapp\node_modules\express\lib\router\index.js:317:13)
at C:\Users\George\Desktop\EXPRESS SERVER LIVE\myapp\node_modules\express\lib\router\index.js:284:7
at Function.process_params (C:\Users\George\Desktop\EXPRESS SERVER LIVE\myapp\node_modules\express\lib\router\index.js:335:12)
at next (C:\Users\George\Desktop\EXPRESS SERVER LIVE\myapp\node_modules\express\lib\router\index.js:275:10)
at C:\Users\George\Desktop\EXPRESS SERVER LIVE\myapp\node_modules\express\lib\router\index.js:635:15
at next (C:\Users\George\Desktop\EXPRESS SERVER LIVE\myapp\node_modules\express\lib\router\index.js:260:14)
at Function.handle (C:\Users\George\Desktop\EXPRESS SERVER LIVE\myapp\node_modules\express\lib\router\index.js:174:3)
at router (C:\Users\George\Desktop\EXPRESS SERVER LIVE\myapp\node_modules\express\lib\router\index.js:47:12)

我不使用routerLink =“home”,因为每当我有一个带有来自物化lib的图像的滑块时我想要刷新页面:http://materializecss.com/media.html

如果我使用routerLink="home"我不会刷新页面,我不会加载图片,我应该为此做些什么?

在localhost 4200中,一切都按预期工作,但不在我的node.js服务器上

当我运行快速服务器时,默认页面运行到目前为止一切正常,但是如果我点击主导航上的链接,我就会收到错误。

这是nav组件

<ul class="right hide-on-med-and-down">
    <li><a href="arxiki">Αρχική</a></li>
    <li><a href="omilos">Όμιλος</a></li>
    <li><a href="kopilasia">Κοπηλασία</a></li>
    <!-- Dropdown Trigger -->
    <li><a class="dropdown-button" href="#!" data-activates="dropdown1">Dropdown<i class="material-icons right">arrow_drop_down</i></a></li>
</ul>

我使用href属性,因为页面必须重新加载。

routing.module.ts

export const router: Routes = [
  { path: '', redirectTo: 'arxiki', pathMatch: 'full' }, // this will make your component the landing page
  { path: 'login', component: LoginComponent },
  { path: 'members', component: MembersComponent, canActivate : [AuthGuard] },

  { path: 'arxiki', component: ArxikiComponent },
  { path: 'omilos', component: OmilosComponent },
  { path: 'kopilasia', component: KopilasiaComponent },
  { path: 'admin', component: AdminLoginPageComponent },
  { path: '404', component: NotFoundComponent },
  { path: '**', redirectTo: '/404' }
]

0 个答案:

没有答案