How do I get the text of a select with formBuilder? - Angular 6

0

I would like to get the value of the text and not the value of the select.

      <div class="form-group col-md-3">
        <label for="ProductName">Product Name</label>
        <select id="ProductName" class="form-control" formControlName='ProductName' autofocus #focusHere (change)="retrieveID()">
          <option *ngFor="let productName of productNames" [value]="productName.id">{{ productName.ProductName }}</option>
        </select>
        <small *ngIf="productForm.get('ProductName').errors?.required" class="text-danger d-block mt-2">Product Name is
          required!
        </small>
      </div>

Follow the logic.

   registerProduct() {
    this.products.push({
      ProductName: this.productForm.get('ProductName').value,
      ProductElement: this.productForm.get('ProductElement').value,
      ProductAttribute: this.productForm.get('ProductAttribute').value,
      ProductAttributeValue: this.productForm.get('ProductAttributeValue').value,
      Quantity: this.productForm.get('Quantity').value,
      FK_ID_QUOTE: this.quote.id
    })

    this.productForm.reset()
    this.focusHere.nativeElement.focus()
    return this.products
  }

I need to get the value of the text and the value of the value (id, name).

    
asked by anonymous 01.10.2018 / 18:32

1 answer

-1

No ts:

objeto: any;

No html:

<select id="ProductName" class="form-control" formControlName='ProductName' autofocus #focusHere (change)="retrieveID()" [(ngModel)]="objeto">

That's pretty basic, man. Take a look at the angular course on youtube. It has several. Start there, or in the Angular official tour of heroes . I recommend Loiane Groner's Angular Course: here or here

    
01.10.2018 / 18:53