First of all, I am a complete newbie in this kind of programming with nodejs, angular2 and typescript. I basically start reading https://angular.io/docs/ts/latest/guide/forms.html and https://angular.io/docs/ts/latest/guide/router.html#!#base-href to expand my application on new pages. I am using mdl to use material components in my application.
angular 2, it seems manual reboot and routing are different, so I get the following problem:


I am trying to understand what is happening, can someone explain to me what is the difference between reloading and routing in angular2 and how can I fit in the routing processing on reload behavior?
Update No. 1:
index.html:
<!doctype html> <html> <head> <meta charset="utf-8"> <title>Title</title> <script defer src="/assets/js/material.min.js"></script> <link rel="stylesheet" href="/assets/css/font-awesome.min.css"> <link rel="stylesheet" href="/assets/css/material.min.css"> <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> <base href="/"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="icon" type="image/x-icon" href="favicon.ico"> </head> <body> <app-root><md-spinner></md-spinner></app-root> </body> </html>
app.module.ts
import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { HttpModule } from '@angular/http'; import { AppComponent } from './pages/layout/app.component'; import { HomeComponent } from './pages/home/app.component'; import { LoginComponent } from './pages/myaccount/login.component'; import { NotFoundComponent } from './pages/error/404.component'; import { RegisterComponent } from './pages/myaccount/register.component'; import { RouterModule, Routes } from '@angular/router'; import { LoginService } from './service/LoginService'; const appRoutes: Routes = [ { path: '', component: HomeComponent }, { path: 'series', component: AppComponent }, { path: 'login', component: LoginComponent }, { path: 'register', component: RegisterComponent }, { path: '**', component: NotFoundComponent } ]; @NgModule({ declarations: [ AppComponent, LoginComponent, HomeComponent, RegisterComponent, NotFoundComponent ], imports: [ BrowserModule, FormsModule, HttpModule, RouterModule.forRoot(appRoutes) ], providers: [LoginService], bootstrap: [AppComponent] }) export class AppModule { }
register.html:
<div class="mdl-grid iv-padding" > <div class="mdl-layout-spacer"></div> <div class="mdl-cell mdl-cell--4-col"> <div style="text-align:center;"> <form (ngSubmit)="onSubmit()"> <div class="iv-card-wide mdl-card mdl-shadow--2dp"> <div class="mdl-card__title"> <h2 class="mdl-card__title-text">Registrierung</h2> </div> <div class="mdl-card__supporting-text"> <div class="text-field mdl-textfield mdl-js-textfield"> <input class="mdl-textfield__input" required [(ngModel)]="model.username" name="username" type="text" id="username"> <label class="mdl-textfield__label" for="username" >Username</label> </div> <br /> <div class="text-field mdl-textfield mdl-js-textfield"> <input class="mdl-textfield__input" [(ngModel)]="model.password" name="password" type="password" id="password"> <label class="mdl-textfield__label" for="password">Password</label> </div> <br /> <div class="text-field mdl-textfield mdl-js-textfield"> <input class="mdl-textfield__input" [(ngModel)]="model.email" name="email" type="email" id="email"> <label class="mdl-textfield__label" for="email">E-Mail</label> </div> </div> <div class="mdl-card__actions mdl-card--border"> <button type="submit" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent">Registrieren</button> </div> </div> </form> </div> </div> <div class="mdl-layout-spacer"></div> </div>
RegisterComponent
import { Component } from '@angular/core'; import { User } from '../../objects/user'; @Component({ selector: 'app-root', templateUrl: './register.component.html', styleUrls: ['./register.component.css'] }) export class RegisterComponent { model = new User(0, "", "", ""); submitted = false; onSubmit() { console.log("PW" + this.model.password); } }