0

Hi guys i have a form with

this.crudForm = this.formBuilder.group({
      id: null,
      company: Company,
      document: Document,
      serie: Series,
      documentNumber: null,
      comment: '',
      note: '',
      reference: '',
      registryDate: new Date,
      validityDate: new Date,
      salesState: SALES_STATE_PRESALE,
      salesRef: Sales,
      igv: 0,
      igvTotalNC: 0,
      salesTotalNC: 0,
      netoTotalNC: 0,
      discountTotalNC: 0,
      igvAmount: 0

    });

and i want to get the value of salesState but in the front , so depending the value i do some stuff and im using this :

<div class="col-md-offset-7 col-md-1"><p class="align-status"><mat-icon matSuffix [ngStyle]="addStyles(crudForm.get('salesState').value)">stop</mat-icon>VENTA</p></div>

but is not working , its like im not getting the value. Also de salesState gets diferent value depending the STATE of the Sale but that is working . and this is the function on ts:

addStyles(a){
    let myStyle = {
      'color' : a === 2 ? 'green' : 'blue',
    }
    return myStyle
  }

Any ideas??

I would be very grateful

Paul VH
  • 21
  • 1
  • 1
  • 6

1 Answers1

0

Use

crudForm.controls['salesState'].value

as a parameter to addStyles function

like this:

<div class="col-md-offset-7 col-md-1"><p class="align-status"><mat-icon matSuffix [ngStyle]="addStyles(crudForm.controls['salesState'].value)">stop</mat-icon>VENTA</p></div>
siddharth shah
  • 1,139
  • 1
  • 9
  • 17