Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. import { NgModule } from '@angular/core';
  2. import { RouterModule, Routes } from '@angular/router';
  3.  
  4. import { LoginComponent } from '../Components/login.component';
  5. import { MenuComponent } from '../Components/menu.component';
  6.  
  7. const routes: Routes = [
  8. { path: '', redirectTo: '/login', pathMatch: 'full' },
  9. { path: 'login', component: LoginComponent },
  10. { path: 'menu', component: MenuComponent }
  11. ];
  12.  
  13. @NgModule({
  14. imports: [ RouterModule.forRoot(routes) ],
  15. exports: [ RouterModule ]
  16. })
  17. export class AppRouter {}
  18.  
  19. import { Component } from '@angular/core';
  20. import { Router } from '@angular/router';
  21.  
  22. @Component({
  23. templateUrl: '../Templates/login.component.html'
  24. })
  25. export class LoginComponent {
  26. title = 'app works!';
  27. username: string = 'user';
  28. password: string = 'password'
  29.  
  30. constructor(private router: Router){
  31.  
  32. }
  33.  
  34. validate(): void{
  35. if(this.username === "user" &&
  36. this.password === "password"){
  37. console.log("Logged In!");
  38. this.router.navigate(['../main']);
  39. }
  40. else {
  41. console.log(this.username + ' ' + this.password);
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement