source: Farmatiko/ClientApp/src/app/dialogs/add-medicine-dialog/add-medicine-dialog.component.ts@ de9d697

Last change on this file since de9d697 was 8b13eb2, checked in by DimitarSlezenkovski <dslezenkovski@…>, 4 years ago

fix bugs

  • Property mode set to 100644
File size: 1.2 KB
Line 
1import { Component, OnInit } from '@angular/core';
2import { MatDialogRef } from '@angular/material/dialog';
3import { IMedicine } from '../../shared';
4import { FormGroup, Validators, FormBuilder } from '@angular/forms';
5
6@Component({
7 selector: 'app-add-medicine-dialog',
8 templateUrl: './add-medicine-dialog.component.html',
9 styleUrls: ['./add-medicine-dialog.component.css']
10})
11export class AddMedicineDialogComponent implements OnInit {
12 medicine: IMedicine;
13 forma: FormGroup;
14
15 constructor(private dialogRef: MatDialogRef<AddMedicineDialogComponent>, private formBuilder: FormBuilder) {
16
17 }
18
19 ngOnInit(): void {
20 this.forma = this.formBuilder.group({
21 name: ['', [Validators.required]],
22 strength: ['', [Validators.required]],
23 form: ['', [Validators.required]],
24 wayOfIssuing: ['', [Validators.required]],
25 manufacturer: ['', [Validators.required]],
26 price: ['', [Validators.required, Validators.min(0)]],
27 packaging: ['', [Validators.required]]
28 });
29 }
30
31 save() {
32 this.medicine = this.forma.value;
33 console.log(this.forma.value);
34 console.log(this.medicine);
35 this.forma.reset();
36 this.dialogRef.close(this.medicine);
37 }
38
39 close() {
40 this.dialogRef.close();
41 }
42}
Note: See TracBrowser for help on using the repository browser.