angular-reactive-forms

angular 6 warning for using formControlName and ngModel

◇◆丶佛笑我妖孽 提交于 2019-12-17 17:36:42
问题 I recently upgraded the angular version to 6-rc. I got following warning It looks like you're using ngModel on the same form field as formControlName. Support for using the ngModel input property and ngModelChange event with reactive form directives has been deprecated in Angular v6 and will be removed in Angular v7 For more information on this, see our API docs here: https://angular.io/api/forms/FormControlName#use-with-ngmodel What does it say exactly? the link does not have any fragment

Custom Validator on reactive form for password and confirm password matching getting undefined parameters into Angular 4

可紊 提交于 2019-12-17 08:48:13
问题 I'm trying to implement a custom validator to check if the password and password confirm are equal. The problem is that the validator is getting undefined password and confirmedPassword parameters. How do I make this work. The function works cause if I change the condition to === instead of !== it throws the error correctly when the fields are the same. Does anyone know which is the error here? signup.component.html <div class="col-md-7 col-md-offset-1 col-sm-7"> <div class="block"> <div

Angular 4 validator to check 2 controls at the same time

假装没事ソ 提交于 2019-12-17 05:15:45
问题 I have a reactive form with 2 controls (port_start and port_end) that have the following requirements: Both must have a value Their values must be between 0 and 65535 port_start value must be less than port_end value This is what I tried so far: [...] this.formModel.addControl('port_start', new FormControl(object.port_start ? object.port_start : 0, [Validators.required, Validators.min(0), Validators.max(65535), this.minMaxValidator('port_start', 'port_end').bind(this)])); this.formModel

Angular 4 validator to check 2 controls at the same time

妖精的绣舞 提交于 2019-12-17 05:15:20
问题 I have a reactive form with 2 controls (port_start and port_end) that have the following requirements: Both must have a value Their values must be between 0 and 65535 port_start value must be less than port_end value This is what I tried so far: [...] this.formModel.addControl('port_start', new FormControl(object.port_start ? object.port_start : 0, [Validators.required, Validators.min(0), Validators.max(65535), this.minMaxValidator('port_start', 'port_end').bind(this)])); this.formModel

How to pass reactive form data between child to parent components with out using services

扶醉桌前 提交于 2019-12-14 03:45:51
问题 We would like to consume child reactive form data from parent when we click on parent button. Currently we are using viewchild for getting the child cpomponent reference. We are getting all static data but not the form filled data....................................................................................................... parent.component.ts @ViewChild(DetailsComponent) childrenComponent: childrenComponent; save(){ let model=this.childrenComponent.buildDetailsModel(); /*here api to

Allow Input Quantity Based On Available Quantity in Reactive Forms

走远了吗. 提交于 2019-12-14 03:08:49
问题 I need help in my problem since i need to input only the quantity based on the available quantity on my rows? How can i only submit the button if this requirement is met? How can i check for this? Here's the link LINK CODES initGroup() { let rows = this.addForm.get('rows') as FormArray; rows.push(this.fb.group({ ingredient_id: ['', Validators.required], qty_available: new FormControl({ value: '', disabled: true }, Validators.required), qty: ['', Validators.required] })) } 回答1: //when push the

Nested dynamic array forms in Angular Reactive forms

心已入冬 提交于 2019-12-13 17:43:48
问题 I'm having a array form namely "address" and this will be a dynamic once the user clicks the "Add Address" button immediately one address form will add. I implemented this with an issue (Add/Remove address works fine). Now I need to add a dynamic contact numbers similar like address. A address may contain one or more than one phone numbers, if the user clicks "Add Phone number" need to add a new phone number form inside the address form, the functionality will required in all the address

Pushing Iterated Rows Depending on Number Selected in Reactive Forms in Angular

扶醉桌前 提交于 2019-12-13 15:46:16
问题 I've a problem in iterating rows when i selecting a number in my dropdown. How would i push that number so that rows(cards) would be iterated depending on that number. My process is this, first you have to select Solo Traveller as 'No' so that the adults and children dropdowns would appear. That dropdown is my problem, how would i iterate rows(cards) depending on that number selected? I've made the rows(cards) but i don't know how would i iterate it. here's my stackblitz link CLICK THIS LINK

Set value of <mat-select> programmatically

帅比萌擦擦* 提交于 2019-12-13 11:36:25
问题 I'm trying to set value of 2 fields <input matInput> abnd <mat-select> programatically. For text input everything works as expected however for the <mat-select> on the view this field is just like it would have value off null . But if I would call console.log(productForm.controls['category'].value it prints correct value that I set programmatically. Am I missing something? Here is the code: form config: productForm = new FormGroup({ name: new FormControl('', [ Validators.required ]), category

Angular 2+, why doesn't material want to show error message?

自作多情 提交于 2019-12-13 09:04:05
问题 I want to confirm the passwords, but when I wrote the logic of validator and send it to the mat-error the message haven't shown, but the validator work normally, how fix this moment in reactive forms in my case?? export class SignUpComponent implements OnInit { profileForm: FormGroup; constructor( private userService: UserService, private formBuilder: FormBuilder ) { this.profileForm = this.formBuilder.group({ name: ['', [Validators.required, Validators.pattern(/^[a-zA-Z0-9_ -]+$/)]], email: