angular-formbuilder

How to set individual option list for selects in a formbuilder

只愿长相守 提交于 2021-02-11 13:25:00
问题 I have a model driven form with 2 selects, 'State' and 'City'. The models looks something as below : class State{ stateID : number; stateName : String, cities : City[] } class City{ cityID : number, cityName : String } I am populating the city option list from the selection of state as I have all the data available in State[] 'stateList'. <select formControlName="state" (onchange)="getCityNameByState($event.target.value)"> <option *ngFor="let stateName of stateList" [value]= "stateID"> {

Angular Subscribe valuechanges in formarray in form group

非 Y 不嫁゛ 提交于 2021-01-05 07:41:56
问题 I'm angular8 and I have a form array inside of form group but I want to detect new changes of a certain input. ngOnInit(): void { this.makeForm = this.fb.group({ year:['', Validators.required], amount:['', Validators.required], desc:['', Validators.required], details: new FormArray([ this.det(), ]) }) det(){ return new FormGroup({ requestfor : new FormControl(''), remarks : new FormControl(''), // file_id : new FormControl(''), })} I have to check the data that every value changes in

Getting an error: formGroup expects a FormGroup instance. Please pass one in

无人久伴 提交于 2020-01-25 06:54:49
问题 I am trying to use reactive forms for dynamic values added on click of button. I am getting below error: formGroup expects a FormGroup instance. Please pass one in Here is my example: dynamic-reactive-forms I am new to reactive forms . Some code in ts file: let numberOfTiles = document.getElementsByClassName("tiledata").length; if (this.t.length < numberOfTiles) { for (let i = this.t.length; i < numberOfTiles; i++) { this.t.push(this.formBuilder.group({ tabName: ['', Validators.required],

Angular Reactive Form submit and clear validation

只愿长相守 提交于 2019-12-24 14:05:39
问题 I have a reactive form <form [formGroup]="secondFormGroup"> <ng-template matStepLabel>enter items</ng-template> <div style="display: flex; flex-direction: column;"> <mat-form-field> <input matInput type="text" placeholder="category" [(ngModel)]="newItem.CategoryName" formControlName="category" /> </mat-form-field> <mat-form-field> <input matInput type="text" placeholder="sub category" [(ngModel)]="newItem.SubCategoryName" formControlName="subCategory" /> </mat-form-field> <mat-form-field>

Set Value Not Less Than 0 In FormArray Reactive Forms

二次信任 提交于 2019-12-11 04:29:14
问题 I have successfully implemented the value in the input field to not less than 1 in the "quantityControl" formControlName. However my problem is when on the formArray. How can i set that to not than less than 0 or should not be a negative number? Here's the code below and the link to my stackblitz CODE LINK this.inquiryForm.get('quantityControl').valueChanges.pipe( filter(quantity => quantity < 1) ).subscribe(value => { console.log(value); this.inquiryForm.get('quantityControl').setValue(1); }