我已经在网上搜索了解如何在手动输入url(或页面刷新)时如何导航到Angular2中的特定组件。我找不到任何东西,除了beta2 angular2的实施几乎2岁(Such as here)。我有一个简单的使用node/express的角度web应用程序。获得客户端导航工作正常,但让客户端处理服务器请求我不知道这是如何工作,甚至如何实现。任何人都可以帮忙Angular2服务器url导航
我只是简单地做: http://localhost:3000/login - 这适用于在应用程序中导航,但是当我刷新它不起作用。我想如果简单地实现这一点,将会有大量的资源,但是我没有找到基本的东西。谢谢!
main.ts:
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { LocationStrategy, HashLocationStrategy } from '@angular/common';
import { AppModule } from './app.module';
platformBrowserDynamic().bootstrapModule(AppModule);
app.module.ts:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule } from '@angular/router';
import { AppComponent } from './components/app.component';
import { LoginComponent } from './components/auth/login';
import { IndexComponent } from './components/home/index';
import { PageNotFoundComponent } from './components/not-found.component';
@NgModule({
imports: [ BrowserModule,
RouterModule.forRoot([
{
path: 'login',
component: LoginComponent
},
{
path: '',
component: IndexComponent
},
{ path: '**', component: PageNotFoundComponent }
])],
declarations: [ AppComponent,IndexComponent,LoginComponent,PageNotFoundComponent ],
providers: [ ],
bootstrap: [ AppComponent ]
})
export class AppModule { }