source: Farmatiko/ClientApp/src/app/login/login.component.ts@ 6f203af

Last change on this file since 6f203af 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
RevLine 
[785b8bd]1import { Component, OnInit } from '@angular/core';
[ee137aa]2import { FormGroup, FormControl, Validators } from '@angular/forms';
3import { Router, ActivatedRoute } from '@angular/router';
4import { DataService } from '../shared/data.service';
[785b8bd]5
6@Component({
7 selector: 'app-login',
8 templateUrl: './login.component.html',
9 styleUrls: ['./login.component.css']
10})
11export 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.