angular-reactive-forms

How to edit or add one row at a time using reactive forms in angular8

风流意气都作罢 提交于 2020-02-12 05:20:10
问题 I have a list of data, when i click on rows, all the rows are editable and when i click on edit button of the expanded row, all the rows will have the same value as in the first row, but that shouldnt happen.One row can be editable at a table, when clicked on edit button in the expanded row, add new should also not be done. But i am going wrong somewhere, can anyone help me. DEMO: DEMO TS: eoEdit(eo) { console.log(eo) this.eoDetailsList = eo this.hideEoView = false; this.initEoForm() } HTML:

How to dynamically add inputs value to angular component?

烂漫一生 提交于 2020-02-06 08:03:02
问题 I am getting array of questions that i am populating sequentially in modal window so inputs i have in formGroup are based on questions , SO i am trying to assign values as you can see formatSubQuestions method when everytime sinle question answer submitted using getNextQuestion . The problem is CURRENT_TEXT always come empty string and TEXT_NUMBER and TEXT_DATE always have same values. Only ALLERGY_DETAILS always get correct values. All these inputs may not be part of same question. What is

How to dynamically add inputs value to angular component?

三世轮回 提交于 2020-02-06 08:02:06
问题 I am getting array of questions that i am populating sequentially in modal window so inputs i have in formGroup are based on questions , SO i am trying to assign values as you can see formatSubQuestions method when everytime sinle question answer submitted using getNextQuestion . The problem is CURRENT_TEXT always come empty string and TEXT_NUMBER and TEXT_DATE always have same values. Only ALLERGY_DETAILS always get correct values. All these inputs may not be part of same question. What is

Mixing Reactive Form with Template Form

帅比萌擦擦* 提交于 2020-01-30 12:57:25
问题 I have built a big form with lots of input using Template Form. Now I have got a requirement to add a part of input dynamically. Since adding inputs dynamically seems easier with Reactive Form, I would like to change that specific part of inputs to Reactive Form. So is it possible to mix reactive forms and template forms in a same form tag? 回答1: You can mix both reactive forms and template driven forms, but it is highly not recommended. This is because using ngModel on reactive forms goes

how to validate for input type file-size in reactive form

半腔热情 提交于 2020-01-26 03:55:06
问题 I am not getting FileList for selected file. When we console the event.target.files[0], it show undefined. Expected - If we get the event.target.files[0], then we can access file-size. HTMl <small *ngIf="FileUpload.errors?.fileSizeValidator" class="text-danger">File size is required</small> fileSizeValidator.TS import { AbstractControl, FormControl } from "@angular/forms"; export function fileSizeValidator(event: any) { return function(control: FormControl) { // return (control:

Remove the selected option from select box

佐手、 提交于 2020-01-25 09:11:27
问题 I am making angular application with angular form. Here i have given a form with input fields first name and last name which will always showing.. After that i am having children which will be displayed upon clicking the add button and the children will get removed on click remove button. As of now everything works fine. Here i am making patching of data to the inputs on click option from select box.. The neccessary inputs gets patched.. HTML: <div> <form (ngSubmit)="onSubmit()" [formGroup]=

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 Use Child Component Form in Parent Component Nested Form

╄→尐↘猪︶ㄣ 提交于 2020-01-24 22:34:44
问题 Whats the best way to place a ChildComponent form into a Parent Component Form? We are using the latest Angular 8 in 2019. The following methods below after research do not work fully. Parent Component: ngOnInit() { this.parentForm = this.fb.group({ childForm1: etc }) Child Component: this.ChildForm = this.formBuilder.group({ 'streetNumber': [null, [Validators.required, Validators.maxLength(32)]], 'streetType': [null, [Validators.maxLength(8)]], 'city': [null, [Validators.maxLength(32)]],

Cannot read property of undefined Reactive Forms

只谈情不闲聊 提交于 2020-01-24 21:29:46
问题 I am trying to make a custom validator for password but I don't get why I get the following error ERROR TypeError: Cannot read property 'f' of undefined Below is my code: registerForm: FormGroup; submitted = false; constructor(private Auth:AuthService, private router:Router,private formBuilder:FormBuilder) { } ngOnInit() { this.registerForm = this.formBuilder.group({ userName: ['', Validators.compose([Validators.required,Validators.minLength(6),Validators.maxLength(30),Validators.pattern('^[a

Angular Material: How to validate Autocomplete against suggested options?

偶尔善良 提交于 2020-01-24 02:23:08
问题 We have an autocomplete input with required validation. When a user searches for an option by entering a query (but doesn't pick any of the options) then the input is valid, even though it doesn't match any of the suggested options. What I want to achieve is not permitting the user to post the form unless one of the suggested options is selected. How do I achieve this? <mat-form-field> <input matInput placeholder="Pick one" aria-label="pick one" [matAutocomplete]="auto" [formControl]="form