我已經在網上搜索瞭解如何在手動輸入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 { }