Open SWS-5007 opened 1 year ago
Class import { Component, ViewChild, OnInit, EventEmitter, Output } from "@angular/core"; import { FormBuilder, FormGroup, FormControl, FormArray } from '@angular/forms';
Class
import { Component, ViewChild, OnInit, EventEmitter, Output } from "@angular/core"; import { FormBuilder, FormGroup, FormControl, FormArray } from '@angular/forms';
@Component({ selector: "", templateUrl: "", styleUrls: [""], })
export class Component implements OnInit { constructor( ) { }
manualSalesFormdata = new FormArray([]);
ngOnInit() {
}
get manualSaleEveryData() { return this.manualSalesFormdata.get("datas") as FormArray; }
onSubmit(data) { console.log('$$$$$$%%%%%%%%@@@@@@@@', data) }
for (let j = 0; j <= number; j++) { const group = new FormGroup({ total: new FormControl(''), cash: new FormControl(''), card: new FormControl('') }); this.manualSalesFormdata.push(group); }
>HTML
<form (ngSubmit)="onSubmit(manualSalesFormdata.value)">
{{date | date:'EEEE'}}
{{date | date:'dd/MM/YYYY'}}
</div> <button type="submit" class='btn btn-success'>Sumbit</button>
How to create FormGroup on Loop?
@Component({ selector: "", templateUrl: "", styleUrls: [""], })
export class Component implements OnInit { constructor( ) { }
manualSalesFormdata = new FormArray([]);
ngOnInit() {
}
get manualSaleEveryData() { return this.manualSalesFormdata.get("datas") as FormArray; }
onSubmit(data) { console.log('$$$$$$%%%%%%%%@@@@@@@@', data) }
}
<form (ngSubmit)="onSubmit(manualSalesFormdata.value)">
Sales
{{date | date:'EEEE'}}
{{date | date:'dd/MM/YYYY'}}