### File

`src/app/Views/dashboard/user-dialog/user-dialog.component.ts`

### Metadata

selector | `app-user-dialog`
styleUrls | `user-dialog.component.scss`
templateUrl | `user-dialog.component.html`

### Constructor

`constructor(dataService: any, dialog: MatDialog, dialogRef: any, data: TransactionData)`

### Methods

onSubmit
`onSubmit()`
Returns: `void`

### Properties

countValid
`countValid: `boolean` </bcode>`
Default value: `true`

data
`data: `TransactionData` </bcode>`

dialog
`dialog: `MatDialog` </bcode>`

dialogRef
`dialogRef: `any` </bcode>`

priceValid
`priceValid: `boolean` </bcode>`
Default value: `true`

    import { Component, Inject, OnInit } from '@angular/core';
    import { FormControl } from '@angular/forms';
    import {
      MatDialog,
      MatDialogRef,
      MAT_DIALOG_DATA,
    } from '@angular/material/dialog';
    import { DataService } from 'src/app/Services/data.service';

    import { TransactionData } from '../dashboard.component';

    @Component({
      selector: 'app-user-dialog',
      templateUrl: './user-dialog.component.html',
      styleUrls: ['./user-dialog.component.scss'],
    })
    export class UserDialogComponent {
      constructor(
        private dataService: DataService,
        public dialog: MatDialog,
        public dialogRef: MatDialogRef<UserDialogComponent>,
        @Inject(MAT_DIALOG_DATA) public data: TransactionData
      ) {}

      countValid = true;
      priceValid = true;

      onSubmit() {
        console.log(!isNaN(this.data.count));
        if (!isNaN(this.data.count) && !isNaN(this.data.price)) {
          this.priceValid = true;
          this.countValid = true;
          console.log(
            this.dataService
              .createTransaction(
                this.data.comment,
                this.data.isin,
                this.data.time,
                +this.data.count,
                +this.data.price.toFixed(2) * -1
              )
              .subscribe((data) => {
                console.log(data);
              })
          );
          this.dialog.closeAll();
        } else if (isNaN(this.data.count) && !isNaN(this.data.price)) {
          this.priceValid = true;
          this.countValid = false;
        } else if (!isNaN(this.data.count) && isNaN(this.data.price)) {
          this.priceValid = false;
          this.countValid = true;
        } else {
          this.countValid = false;
          this.priceValid = false;
        }
      }
    }

# results matching ""

# No results matching ""