angular-reactive-forms

Angular 6 Follow up: [attr.disabled] in option value disables all entries

独自空忆成欢 提交于 2019-12-10 10:42:35
问题 Topic: Angular 6, Reactive Form, DropDown Menu, Disable One Option: all instead of just the one intended value are disabled, even though the inspector says disabled=false. People were very kind to help me with my problem earlier: "Angular 6 Reactive Form - Select options: disable previously selected options" but they seemed to disappear after I hit a roadblock, hence my new question: Why are ALL option values disabled instead of just the one that is supposed to match the statement? [attr

How to implement auto save a reactive form in angular 4?

有些话、适合烂在心里 提交于 2019-12-10 09:46:54
问题 I want to auto save content in reactive form when form is valid without clicking save button. 回答1: You will want to subscribe to the statusChanges() method of your FormGroup, and in that Observable you can determine whether the FormGroup is valid and then trigger a save event. import 'rxjs/add/operator/takeWhile'; import { FormBuilder, FormGroup } from '@angular/forms'; @Component({...}) export class MyComponent { private form: FormGroup; private alive: boolean; constructor(private

How to make cascading dropdown in a Angular Reactive Formarray work without messing the dropdown value

依然范特西╮ 提交于 2019-12-10 03:31:40
问题 I have a form in angular 4 that containing First Name + Last Name and a formarray containing 2 dropdown(select) working as cascading dropdown and a delete button. The rest of the form also contains a send button and a add option button. I added a screenshot down here for you to understand better. The forms add , remove button and send button works there is 1 problem the cascading dropdown works only when there is 1 cascading dropdown ,when I add an extra cascading select the value from

Two way binding on angular 6 reactive form

梦想与她 提交于 2019-12-10 02:58:26
问题 I am trying to create a complex reactive form with nested component that is populated with a data object. The behavior I am trying to achieve is very similar to the two-way data binding of a template-driven form: when the user edits an input of the form, the data object is changing automatically . but as opposed to template-driven form, I cannot use [(ngModel)] because it is deprecated in reactive forms for angular V6. I know that fromGroup.patchValue() will only do a one way binding and then

ERROR Missing number at position 0 when using setValue angular 4

别来无恙 提交于 2019-12-10 02:13:47
问题 I'm using Angular 4 with reactiveforms, momentjs, and primeng calendar I'm tying to use setValue and have tried patchValue on a reactiveForm field which contains a Date. This date has been created via a primeng calendar. purchaseDate: Sat Sep 02 2017 00:00:00 GMT+0100 (GMT Daylight Time) I use this 'date' to do a couple of things and then onSumbit of the form I convert the date using momentjs to a clean format ready for the backend to accept (i.e. YYYY.MM.DD) using .moment().format(....

Angular 4: reactive form control is stuck in pending state with a custom async validator

笑着哭i 提交于 2019-12-10 01:17:46
问题 I am building an Angular 4 app that requires the BriteVerify email validation on form fields in several components. I am trying to implement this validation as a custom async validator that I can use with reactive forms. Currently, I can get the API response, but the control status is stuck in pending state. I get no errors so I am a bit confused. Please tell me what I am doing wrong. Here is my code. Component import { Component, OnInit } from '@angular/core'; import { FormBuilder, FormGroup

Angular 7 select dropdown object is empty when not touched

两盒软妹~` 提交于 2019-12-09 18:43:44
问题 In my application, ngOnInit() loads currencies, categories, and manufacturers. I am using Angular 7 reactive forms for this. Data loads as expected and dropdowns populated with values and the first option selected and showed to the user. So, here is the problem, after finishing form and clicking on submit (using default dropdown values), I see an empty object for the category , currency , and manufacturer . ProductNewComponent.ts import {Component, OnInit} from '@angular/core'; import {Router

Update form values both on blur and submit in Angular

﹥>﹥吖頭↗ 提交于 2019-12-09 17:33:03
问题 I am implementing a reactive form in Angular 5, and I need to trigger validation in both events, when the fields are blurred and also when the form is submitted. I have set it to blur using the updateOn property to 'blur', but if you are focused on a field and press enter, the blur event is not triggered, and the value of the field is not updated, unless I click away from the field. As far as I know there is no way of settingn updateOn to both blur and submit. Is there any way of achieving

Angular 6 Reactive Forms : How to set focus on first invalid input

℡╲_俬逩灬. 提交于 2019-12-09 16:57:58
问题 Under my Angular 6 app , i'm using Reactive Forms . My purpose is when submitting , i want to set focus on first invalid input when error. My form looks like this : <form [formGroup]="addItemfForm " (ngSubmit)="onSubmitForm()"> <div class="form-inline form-group"> <label class="col-md-2 justify-content-start"> Libellé du pef <span class="startRequired mr-1"> *</span> </label> <input type="text" maxlength="100" formControlName="libellePef" class="col-md-6 form-control" placeholder="saisie

Best way to associate checkbox control with textbox control

坚强是说给别人听的谎言 提交于 2019-12-09 14:07:23
问题 I've been trying many different methods have been failing all week, I need to be able to associate a checkbox control with an answer. Pretty much, if the checkbox is checked then user must answer the question and it must have a validation of minlength 4. The checkbox will contain a question and answer. So if the user chooses that question he/she must provide an answer. the questions are rendered from the server in an object such as; { question_id: "1", selected: true, EN: "Question 1 - EN",