formgroups

disable FormGroup by using Validators

只谈情不闲聊 提交于 2019-12-20 05:42:01
问题 I had formArray checkbox on my checkboxForm , I need to disabled button submit if no checkbox are checked , I had implement custom validator on my checkboxForm , this is what I had tried; Ts file get formReceivedSummons() { return this.checkboxForm.get('receivedSummons') as FormArray; } ngOnInit() { this.checkboxForm = this.formBuilder.group({ receivedSummons: this.formBuilder.array([]) }); this.getReceivedSummons(); } getReceivedSummons() { this.receivedSummonsSubscription = this

FormGroup validation in “exclusive or”

馋奶兔 提交于 2019-12-13 05:50:50
问题 I have a FormGroup that is composed by 3 input fields: reservationCode, secretCode and barcode. The field barcode is simply reservationCode + '-' + secretCode. (this because barcode is a field that can be found in text and usable with copy+paste function) now, the button that uses these fields have to be active only if barcode has value or if reservationCode and secretCode has value. the logic should be something like: "barcode || reservationCode && secretCode" here's the code of the

how do i bind output values of another component to a form-control in my component

牧云@^-^@ 提交于 2019-12-13 04:39:23
问题 This is my html code which is basically a form. <form [formGroup]="calculatedForm" fxLayout="column" fxLayoutGap="15px" fxLayoutAlign="start space-betwen"> <label for="category">CATEGORY</label> <app-toggle-button-group [items]="categories" [selectedItem]="getselectedCategory()" (valueChange)="updateCategory($event)" [disableButtons]="calculatedForm.value.system"> </app-toggle-button-group> <label for="input_interval">INTERVAL</label> <app-toggle-button-group [items]="inputIntervals"

how to get selected value of dropdown in reactive form

对着背影说爱祢 提交于 2019-12-13 03:19:31
问题 I am trying to get the selected value of the dropdown on change event to be sent on reactive form submission. I have a very similar scenario working for radio based on the answer from how to get selected value of radio in reactive form Here's the code for dropdown <div class="row" *ngIf="question.controls.type.value === 'dropdown'"> <div class="col-md-12"> <div class="form-group__text select"> <label for="type">{{ question.controls.label.value }}</label> <br><br> <select name="value"

Angular 6: How to use FormGroup to create formControlName dynamically?

ε祈祈猫儿з 提交于 2019-12-11 12:09:04
问题 I want formControlName Like this, field_0 field_1 field_2 myObj = { "field_0":"value_0", "field_1":"value_1", "field_2":"value_2", } } 回答1: if you have some like fields=["field_0","field_1","field_2"] You first must create a FormGroup createForm(fields: string[]) { let group: any = {}; fields.forEach(x => { group[x] = new FormControl(); }) return new FormGroup(group); } And, when you want show it <form [formGroup]="form"> <div *ngFor="let field of fields"> <input [formControlName]="field"> <

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

前提是你 提交于 2019-12-10 11:42:21
问题 I am new to Angular 2 and unable to resolve this issue even after going through other stack overflow answers. I have just now started learning angular reactive forms and want to try the first example but am stuck. Please help. Here is the HTML form. <div class="container"> <div class="row"> <div class="col-xs-12 col-sm-10 col-md-8 col-sm-offset-1 col-md-offset-2"> <form [formGroup]="signupForm" (ngSubmit)="onSubmit()"> <div id="user-data"> <div class="form-group"> <label for="username"

how action buttons works in Angular 6-json-schema-form

☆樱花仙子☆ 提交于 2019-12-08 06:33:25
I am trying to understand below JSON base form. I am not able to figure out from where that yellow button "Add Phone number" comes from and how it trigger event to replicate more phone list https://hamidihamza.com/Angular6-json-schema-form/?set=ng-jsf&example=ng-jsf-flex-layout&framework=material-design&language=en What you have is a reactive form - check the stackblitz here The whole form is a FormBuilder group which consists of: FormControls for the static (non-repeatable) part of the form (firstName, lastName etc.) While the phone numbers are Formbuilder Array. Everytime that the 'Add phone

how action buttons works in Angular 6-json-schema-form

萝らか妹 提交于 2019-12-08 05:11:27
问题 I am trying to understand below JSON base form. I am not able to figure out from where that yellow button "Add Phone number" comes from and how it trigger event to replicate more phone list https://hamidihamza.com/Angular6-json-schema-form/?set=ng-jsf&example=ng-jsf-flex-layout&framework=material-design&language=en 回答1: What you have is a reactive form - check the stackblitz here The whole form is a FormBuilder group which consists of: FormControls for the static (non-repeatable) part of the

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

早过忘川 提交于 2019-12-06 14:37:59
I am new to Angular 2 and unable to resolve this issue even after going through other stack overflow answers. I have just now started learning angular reactive forms and want to try the first example but am stuck. Please help. Here is the HTML form. <div class="container"> <div class="row"> <div class="col-xs-12 col-sm-10 col-md-8 col-sm-offset-1 col-md-offset-2"> <form [formGroup]="signupForm" (ngSubmit)="onSubmit()"> <div id="user-data"> <div class="form-group"> <label for="username">Username</label> <input type="text" id="username" formControlName="username" class="form-control"> </div>

Reactive Forms: How to add new FormGroup or FormArray into an existing FormGroup at a later point in time in Angular 7

∥☆過路亽.° 提交于 2019-11-27 05:30:21
In the other examples at StackOverflow there are many questions about using FormGroups in FormArrays. But my question is the opposite. FormArrays have a push method, that makes many things possible. FormGroups have indeed an addControl method for adding simple FormControls. Afaik FormGroups do not have addFormArray or addFormGroup method. Therefore I need your help. Following situation: this.myForm = this.fb.group({ id: this.fb.control([this.book.id]), // or short form `id: [this.book.id],` }); Adding a simple control at a later point in time is easy: this.myForm.addControl('isbn', this.fb