angular-reactive-forms

How to calculate value from multiple inputs using angular reactive forms?

杀马特。学长 韩版系。学妹 提交于 2021-01-28 08:49:29
问题 I'm trying to calculate either discount percent or discount amount from list price using angular 6 reactive forms . form.component.html (simplified) ... <form [formGroup]="productForm"> <mat-form-field class="quat-width"> <span matPrefix>$  </span> <input matInput type="number" name="CostPrice" formControlName="CostPrice"> </mat-form-field> <mat-form-field class="quat-width"> <span matPrefix>$  </span> <input matInput type="number" name="ListPrice" formControlName="ListPrice"> </mat-form

remove specific validator from the formgroup in Angular

落花浮王杯 提交于 2021-01-28 08:32:22
问题 I am looking to remove the specific validator from validator array in order to set the controls again when some values changed. I know normal solution where I need to set validators again and again. checked(event: MatCheckboxClickAction): void { const control = (this.form.get( 'information', ) as FormGroup).controls.data1; if (event) { this.updateRequiredValidator(control); } else { control.setValidators([ Validators.maxLength(9), Validators.minLength(2) ]); control.updateValueAndValidity();

Dynamically Add Rows Based on Condition Using Reactive Forms in Angular

拟墨画扇 提交于 2021-01-28 08:00:51
问题 Is it possible that i will be able to add rows based on certain condition in Angular reactive forms? If yes, please help me do it. I've already started it in my stackblitz. Please check this link https://stackblitz.com/edit/dynamically-add-rows this.addForm.get("items").valueChanges.subscribe(val => { console.log(val); if (val === true) { this.addForm.get("items_value").setValue("yes"); // How to add row here? this.addForm.addControl(rows, 'rows') } if (val === false) { this.addForm.get(

With RxJS how to trigger observables by another action stream

大兔子大兔子 提交于 2021-01-28 07:10:37
问题 So I am trying to build a list component reactively by angular and RxJS. the list has a lot of features like: search by word change page number change page size filter by field(s) sort search service code: private seachItemSubject = new BehaviorSubject<string>(""); private pageLimitSubject = new BehaviorSubject<number>(10); private pageNumberSubject = new BehaviorSubject<number>(0); private orderingSubject = new BehaviorSubject<ListOrder>({}); private filteringSubject = new BehaviorSubject

angular material autocomplete prevents reactive from setValue from working

我与影子孤独终老i 提交于 2021-01-27 17:55:36
问题 Edit: Resolved with Jojofoulk's comment. when using the autocomplete components of angular-material, I'm trying to use setValue to the input form, but its [matAutocomplete] attribute is preventing setValue from showing on the input. Inspecting the reactive control reveals the value is right, and removing [matAutocomplete] makes it work, but with it it's just not showing up. <mat-list-item role="listitem" *ngFor="let skill of curObj.skills;index as ind"> <div> <mat-form-field> <input type=

ng-select multi select checkbox with reactive forms in angular 6

本秂侑毒 提交于 2021-01-26 07:30:21
问题 Please go through the link(https://ng-select.github.io/ng-select#/multiselect-checkbox) to know ng-select multi select checkbox. I am trying to use the ng-select "Group selects children" in my angular 6 application. I am having problem using ng-select "Group selects children" with Reactive Forms instead of template driven forms. I have tired it as <ng-select [items]="userGroupsList" [multiple]="true" bindLabel="name" groupBy="gender" [selectableGroup]="true" [selectableGroupAsModel]="false"

Angular Subscribe valuechanges in formarray in form group

非 Y 不嫁゛ 提交于 2021-01-05 07:41:56
问题 I'm angular8 and I have a form array inside of form group but I want to detect new changes of a certain input. ngOnInit(): void { this.makeForm = this.fb.group({ year:['', Validators.required], amount:['', Validators.required], desc:['', Validators.required], details: new FormArray([ this.det(), ]) }) det(){ return new FormGroup({ requestfor : new FormControl(''), remarks : new FormControl(''), // file_id : new FormControl(''), })} I have to check the data that every value changes in

FormGroup inside FormArray in Angular 2 Reactive Forms

倾然丶 夕夏残阳落幕 提交于 2020-12-05 05:46:51
问题 I failed to get an Angular 2 reactive form to work which has a FormGroup nested in a FormArray . Can somebody show me what is wrong in my setup. Unrelated parts of the code has been omitted for the brevity. Following is my component orderForm: FormGroup = this.fb.group({ id: [''], store: ['', Validators.required], //The part related to the error order_lines: this.fb.array([ this.fb.group({ id: [''], order_id: [], product_id: [], description: ['', Validators.required], unit_price: ['',

FormGroup inside FormArray in Angular 2 Reactive Forms

前提是你 提交于 2020-12-05 05:46:41
问题 I failed to get an Angular 2 reactive form to work which has a FormGroup nested in a FormArray . Can somebody show me what is wrong in my setup. Unrelated parts of the code has been omitted for the brevity. Following is my component orderForm: FormGroup = this.fb.group({ id: [''], store: ['', Validators.required], //The part related to the error order_lines: this.fb.array([ this.fb.group({ id: [''], order_id: [], product_id: [], description: ['', Validators.required], unit_price: ['',

FormGroup inside FormArray in Angular 2 Reactive Forms

亡梦爱人 提交于 2020-12-05 05:46:11
问题 I failed to get an Angular 2 reactive form to work which has a FormGroup nested in a FormArray . Can somebody show me what is wrong in my setup. Unrelated parts of the code has been omitted for the brevity. Following is my component orderForm: FormGroup = this.fb.group({ id: [''], store: ['', Validators.required], //The part related to the error order_lines: this.fb.array([ this.fb.group({ id: [''], order_id: [], product_id: [], description: ['', Validators.required], unit_price: ['',