I have scoured the web for a basic understanding of how to navigate to a specific component in Angular2 when manually typing in the url (or page refresh). I was unable to find anything except beta angular2 implementation almost 2 years old (Such as here). I have a simple angular web application that is using node/express. Getting the client side navigation works fine but getting the client to handle a server request I am not sure how this works or even how to implement. Can anyone help.
I am just simply doing: http://localhost:3000/login - This works fine when navigating in the app but when I refresh it does not work. I would think there would be a ton of resources on how to simply implement this but I had no luck on finding something basic. Thanks!
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 { }