Last change
on this file since ee137aa was ee137aa, checked in by Mile Jankuloski <mile.jankuloski@…>, 4 years ago |
Added DataService and dialogs, all bindings needed implemented
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | import { Component, OnInit } from '@angular/core';
|
---|
2 | import { FormGroup, FormControl, Validators } from '@angular/forms';
|
---|
3 | import { Router, ActivatedRoute } from '@angular/router';
|
---|
4 | import { DataService } from '../shared/data.service';
|
---|
5 |
|
---|
6 | @Component({
|
---|
7 | selector: 'app-login',
|
---|
8 | templateUrl: './login.component.html',
|
---|
9 | styleUrls: ['./login.component.css']
|
---|
10 | })
|
---|
11 | export class LoginComponent implements OnInit {
|
---|
12 | loginForm: FormGroup;
|
---|
13 | email: string;
|
---|
14 | passwd: string;
|
---|
15 | errorMessage: string;
|
---|
16 |
|
---|
17 | constructor(private dataService: DataService,private router: Router, private route: ActivatedRoute) {
|
---|
18 | this.loginForm = new FormGroup({
|
---|
19 | email: new FormControl('', [Validators.required, Validators.email]),
|
---|
20 | password: new FormControl('', [Validators.required])
|
---|
21 | });
|
---|
22 | }
|
---|
23 |
|
---|
24 | ngOnInit(): void {
|
---|
25 | }
|
---|
26 |
|
---|
27 | 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));
|
---|
39 | }
|
---|
40 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.