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
|
Rev | Line | |
---|
[785b8bd] | 1 | import { Component, OnInit } from '@angular/core';
|
---|
[ee137aa] | 2 | import { FormGroup, FormControl, Validators } from '@angular/forms';
|
---|
| 3 | import { Router, ActivatedRoute } from '@angular/router';
|
---|
| 4 | import { DataService } from '../shared/data.service';
|
---|
[785b8bd] | 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;
|
---|
[ee137aa] | 13 | email: string;
|
---|
| 14 | passwd: string;
|
---|
| 15 | errorMessage: string;
|
---|
[785b8bd] | 16 |
|
---|
[ee137aa] | 17 | constructor(private dataService: DataService,private router: Router, private route: ActivatedRoute) {
|
---|
[785b8bd] | 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 |
|
---|
[ee137aa] | 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 | }
|
---|
[785b8bd] | 40 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.