我一直在学习Angular2.在nodejs lite-server上运行时,路由工作正常.我可以转到主(localhost:3000)页面并浏览应用程序.我也可以输入localhost:3000/employee,它将转到请求的页面.
该应用程序最终将存在于Windows IIS 7.5服务器上.如果我从主页面(localhost:2500)开始,路由工作正常,我可以在没有任何问题的情况下通过应用程序.我遇到问题的地方是尝试直接转到主登陆页面以外的页面(localhost:2500/employee).我收到HTTP错误404.0.
这是我的app.component文件,用于处理路由.
import { Component } from '@angular/core';
import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS } from '@angular/router-deprecated';
import { HTTP_PROVIDERS } from '@angular/http';
import { UserService } from './services/users/user.service';
import { LogonComponent } from './components/logon/logon.component';
import { EmployeeComponent } from './components/employee/employee.component';
@Component({
selector : 'opi-app',
templateUrl : 'app/app.component.html',
directives: [ROUTER_DIRECTIVES],
providers: [ROUTER_PROVIDERS, UserService, HTTP_PROVIDERS]
})
@RouteConfig([
{
path: '/',
name: 'Logon',
component: LogonComponent,
useAsDefault: true
},
{
path: '/employee',
name: 'Employee',
component: EmployeeComponent
}
])
export class …Run Code Online (Sandbox Code Playgroud)