login.component.ts 624 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { Component, OnInit } from '@angular/core';
import {Router} from '@angular/router';

@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit {


 constructor(private router: Router) { }

username: string;
password: string;

  ngOnInit() {
  }

  login() : void {
                  if(this.username == 'admin' && this.password == 'admin'){
                   this.router.navigate(["/"]);
                  }else {
                    alert("Invalid credentials");
                  }
                }


}