Changeset 993189e for Farmatiko/ClientApp/src/app/login
- Timestamp:
- 10/30/20 02:04:06 (4 years ago)
- Branches:
- master
- Children:
- 1f4846d
- Parents:
- 6f203af
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Farmatiko/ClientApp/src/app/login/login.component.ts
r6f203af r993189e 2 2 import { FormGroup, FormControl, Validators } from '@angular/forms'; 3 3 import { Router, ActivatedRoute } from '@angular/router'; 4 import { DataService } from '../shared/data.service'; 4 import { first } from 'rxjs/operators'; 5 import { AuthService } from '../shared/auth.service'; 5 6 6 7 @Component({ … … 15 16 errorMessage: string; 16 17 17 constructor(private dataService: DataService,private router: Router, private route: ActivatedRoute) {18 constructor(private authService: AuthService,private router: Router, private route: ActivatedRoute) { 18 19 this.loginForm = new FormGroup({ 19 20 email: new FormControl('', [Validators.required, Validators.email]), … … 26 27 27 28 loginPharmacyHead() { 28 this.dataService.loginPharmacyHead(this.email, this.passwd) 29 .subscribe((id: Number) => { 30 if(id) { 31 this.router.navigate(['/dashboard/' + id]); 32 } 33 else { 34 this.errorMessage = 'There was a problem signing in!'; 35 console.log(this.errorMessage); 36 } 37 }, 38 (err: any) => console.log(err)); 29 this.authService.login(this.email,this.passwd) 30 .pipe(first()) 31 .subscribe((data) => { 32 if(data) { 33 this.router.navigate(['/dashboard']); 34 }}, 35 (err: any) => { 36 this.errorMessage = err.toString(); 37 }); 38 this.loginForm.reset(); 39 39 } 40 40 }
Note:
See TracChangeset
for help on using the changeset viewer.