Ignore:
Timestamp:
08/07/20 10:59:56 (4 years ago)
Author:
Mile Jankuloski <mile.jankuloski@…>
Branches:
master
Children:
63d885e
Parents:
c73269d
Message:

Added DataService and dialogs, all bindings needed implemented

Location:
Farmatiko/ClientApp/src/app/login
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Farmatiko/ClientApp/src/app/login/login.component.html

    rc73269d ree137aa  
    66  <div class="example-container">
    77    <mat-form-field>
    8       <input matInput placeholder="Email" formControlName="email">
     8      <input matInput placeholder="Email" [(ngModel)]="this.email" formControlName="email">
    99    </mat-form-field>
    1010
    1111    <mat-form-field>
    12       <input matInput type="password" placeholder="Password" formControlName="password">   
     12      <input matInput type="password" placeholder="Password" [(ngModel)]="this.passwd" formControlName="password">   
    1313    </mat-form-field>
    1414
    15     <button [disabled]="!loginForm.valid" mat-raised-button color="primary" [routerLink]="['/dashboard']" mat-button>Најави се</button>
     15    <button [disabled]="!loginForm.valid" mat-raised-button color="primary" (click)="loginPharmacyHead()" mat-button>Најави се</button>
    1616  </div>
    1717</form>
  • Farmatiko/ClientApp/src/app/login/login.component.ts

    rc73269d ree137aa  
    11import { Component, OnInit } from '@angular/core';
    2 import { FormBuilder, FormGroup, FormControl, Validators, FormArray } from '@angular/forms';
     2import { FormGroup, FormControl, Validators } from '@angular/forms';
     3import { Router, ActivatedRoute } from '@angular/router';
     4import { DataService } from '../shared/data.service';
    35
    46@Component({
     
    911export class LoginComponent implements OnInit {
    1012  loginForm: FormGroup;
     13  email: string;
     14  passwd: string;
     15  errorMessage: string;
    1116
    12   constructor() {
     17  constructor(private dataService: DataService,private router: Router, private route: ActivatedRoute) {
    1318    this.loginForm = new FormGroup({
    1419      email: new FormControl('', [Validators.required, Validators.email]),
     
    2025  }
    2126
     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  }
    2240}
Note: See TracChangeset for help on using the changeset viewer.