Browse Source

login

kris-branch
Krishna Nanda 4 years ago
parent
commit
1e9009f665
4 changed files with 107 additions and 0 deletions
  1. 3
      login/login.component.css
  2. 36
      login/login.component.html
  3. 25
      login/login.component.spec.ts
  4. 43
      login/login.component.ts

3
login/login.component.css

@ -0,0 +1,3 @@
.descriptionModal{
background-image: url("/assets/Images/download.jpg");
}

36
login/login.component.html

@ -0,0 +1,36 @@
<h1 style="text-align:center;color:darkblue;">
Welcome to Urban Bazaar !!!
</h1>
<div style="text-align:center;"><img src="/assets/Images/Logo.png" alt="Logo"></div>
<p style="text-align:center;color:darkblue;">Kindly please login/signup to experience our service</p>
<form #loginForm="ngForm" (ngSubmit)="login(loginForm)" style="text-align:center;color:forestgreen">
User Name :
<input type="text" name="user.username" placeholder="User Name"[(ngModel)]="user.username" required #username="ngModel" />
<br/><br/>
Password :
<input type="password" name="user.userpassword"placeholder="Password" [(ngModel)]="user.userpassword" required #userpassword="ngModel" />
<br/><br/>
<!-- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -->
<input type="submit" value="Login" />
<div *ngIf="loginForm.submitted && !isFormSubmitted">
<p style="color:red">
Please Enter UserName and Password...
</p>
</div>
</form>
<p style="text-align:center;">OR</p>
<div style="text-align:center;">
<a [routerLink]="['signup']">SignUp</a>
</div>
<!-- <div style="text-align:center;">
<a [routerLink]="['user-profile-details']">EditProfile</a>
</div> -->

25
login/login.component.spec.ts

@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { LoginComponent } from './login.component';
describe('LoginComponent', () => {
let component: LoginComponent;
let fixture: ComponentFixture<LoginComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ LoginComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(LoginComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

43
login/login.component.ts

@ -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 {
}
}
Loading…
Cancel
Save