angular-reactive-forms

Angular 4 form validation on multiple fields

被刻印的时光 ゝ 提交于 2020-04-10 02:51:28
问题 EDIT: What I want to achieve is a validation on one single formControl and not the whole form. The validator should check all atom fields like house number, street etc. and then invalidate the google maps input control. I am programming a form with Google Maps Autocomplete. The user should enter a address into a input field that triggers the Google Maps autocomplete logic. When an address is selected the callback function selects the street, house number etc. and uses the API result to fill

form.valueChanges doesn't emit values for disabled controls

僤鯓⒐⒋嵵緔 提交于 2020-04-06 06:39:25
问题 I have an Angular Reactive form. I subscribe to its value changes and will emit changes to parent component. Some of the controls might get disabled by the user. The problem is that values from disabled controls are missing when form valueChanges are emitted. I've set a basic example. When the checkbox is checked and the email input is disabled, there is no form control value logged. But I'd like to get ALL form values. 回答1: Use the FormGroup's getRawValue() to include control values

How to bind array of objects to formGroup and formarray using angular8

纵然是瞬间 提交于 2020-04-03 10:46:10
问题 Hi i have used reactive forms to bind array of objects to formArray, but here if i select any one item in one section and click of move to right/move to left, then the entire object has been moved from one section to other. But that functionality is working fine but i am unable to detect the chnages made from one section to other in the form.valuechanges(). Can anyone help me to detect the changes incase items has been moved from one section to other, and here i want the change detection but

Add FormControl accroding to the data returned from backend but got two different error in Angular app

做~自己de王妃 提交于 2020-03-04 19:00:20
问题 This is one of the page of my Angular app. Inside the ngOnInit method, I call the api twice to get different data I need and loop through the data by using forEach method to build reactive form, but somehow, I encountered one of two different error. This enter image description here and this enter image description here and sometime there is no error at all. It would be grateful if someone can tell me what's wrong with my code. here is part of my code user-manager.component.ts export class

ngModel on the same form field as formControlName

落花浮王杯 提交于 2020-03-01 05:55:09
问题 I used to have a simple form without any validation where the HTML roughly looked like this: <mat-form-field> <input matInput type="text" placeholder="TaskName" [(ngModel)]="todoListService.toDoData.taskName" formControlName="taskName" required required> [(ngModel)]="todoListService.toDoData.taskName" > </mat-form-field> I then moved my form to reactive forms and received the warning that I can't have ngModel on the same field as formControlname. Struggling how I'm supposed to assign the data

Angular 2/4 : Reactive forms are synchronous while template-driven forms are asynchronous, How?

こ雲淡風輕ζ 提交于 2020-02-28 07:42:30
问题 I was going through the doc of angular.io (Reactive forms are synchronous), trying to understand the reactive forms (how they are synchronous and template driven forms are asynchronous). But the doc doesn't have enough explanation with example . Can anyone help me understand how template driven forms are asynchronous and reactive forms are synchronous? I tried to explore a lot of blogs on the internet but didn't get an answer. Any help is appreciated. 回答1: Read this line careful in same

How to throw validation message, when there is some change in the edit item using angular8

送分小仙女□ 提交于 2020-02-16 10:41:53
问题 The bounty expires in 12 hours . Answers to this question are eligible for a +50 reputation bounty. Bhrungarajni is looking for an answer from a reputable source : “I would give 50 reputation of my own if i get proper answer to this question” I am using reactive forms formArray to add the section of data on click of add, and on click of edit, after editing i have used delete and save button to save to the table. So basically one operation at a time must be done. So, when i click on edit, Add

How to throw validation message, when there is some change in the edit item using angular8

懵懂的女人 提交于 2020-02-16 10:40:04
问题 The bounty expires in 12 hours . Answers to this question are eligible for a +50 reputation bounty. Bhrungarajni is looking for an answer from a reputable source : “I would give 50 reputation of my own if i get proper answer to this question” I am using reactive forms formArray to add the section of data on click of add, and on click of edit, after editing i have used delete and save button to save to the table. So basically one operation at a time must be done. So, when i click on edit, Add

Toggle Multiple Fields On/Off in Formbuilder, clean syntax in Angular?

冷暖自知 提交于 2020-02-14 02:06:57
问题 We have a Formbuilder with multiple fields. Sometimes, requirements want to toggle certain fields. We can turn them off with If statements validators, and use NgIf in the html. Is there an easy way to toggle multiple fields on a 20 field form, and simplify the syntax? Is it possible with Formbuilders, or do we have to transfer to form array? Syntax below seems repetitive, curious how it can be simplified, Currently, have around 20 flag fields. { this.customerForm = this.formBuilder.group({

Toggle Multiple Fields On/Off in Formbuilder, clean syntax in Angular?

℡╲_俬逩灬. 提交于 2020-02-14 02:06:29
问题 We have a Formbuilder with multiple fields. Sometimes, requirements want to toggle certain fields. We can turn them off with If statements validators, and use NgIf in the html. Is there an easy way to toggle multiple fields on a 20 field form, and simplify the syntax? Is it possible with Formbuilders, or do we have to transfer to form array? Syntax below seems repetitive, curious how it can be simplified, Currently, have around 20 flag fields. { this.customerForm = this.formBuilder.group({