|
|
|
@ -0,0 +1,43 @@ |
|
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
|
import { NgForm } from '@angular/forms'; |
|
|
|
import { Router } from '@angular/router'; |
|
|
|
|
|
|
|
import { User } from 'src/app/models/user'; |
|
|
|
import { UserService } from 'src/app/services/user.service'; |
|
|
|
|
|
|
|
@Component({ |
|
|
|
selector: 'app-login', |
|
|
|
templateUrl: './login.component.html', |
|
|
|
styleUrls: ['./login.component.css'] |
|
|
|
}) |
|
|
|
export class LoginComponent implements OnInit { |
|
|
|
// logindata={ emailid: '',
|
|
|
|
// passWord: ''}
|
|
|
|
user:User |
|
|
|
isFormSubmitted : boolean; |
|
|
|
login(loginForm : NgForm) { |
|
|
|
// console.log(this.logindata)
|
|
|
|
console.log(this.user) |
|
|
|
if (loginForm.invalid) { |
|
|
|
return; |
|
|
|
} |
|
|
|
// this.isFormSubmitted=true;
|
|
|
|
// this._userService.loginUser(this.user).subscribe(x => { alert("Signup Successful")})
|
|
|
|
|
|
|
|
if (this.user.username=="shawn@mail.com" && this.user.userpassword=="1234") { |
|
|
|
alert("Correct Credentials..."); |
|
|
|
this._router.navigate(['home']) |
|
|
|
} else { |
|
|
|
alert("Invalid Credentials...") |
|
|
|
} |
|
|
|
} |
|
|
|
constructor(private _userService:UserService,private _router:Router) { |
|
|
|
this.user =new User() |
|
|
|
this.isFormSubmitted=false; |
|
|
|
} |
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |