angular-reactive-forms

Custom Component MdDatePicker used in reactive Form

孤街浪徒 提交于 2020-01-11 13:15:09
问题 I am trying to create a custom component to be used in a angular formGroup. Here's is how I want to use this custom component: <form [formGroup]="form"> ... <app-date-picker formControlName="dateStart" [isConsultation]="isConsultation" [label]="'Du'" [(ngModel)]="agenda.datDeb"> </app-date-picker> ... </form> Problem : In the main component (containing this form), The model doesn't get updated when the value changes in my custom component, which is involving a MdDatePicker. Though I am using

display checkbox based on object response Angular

喜欢而已 提交于 2020-01-11 12:34:11
问题 I want to create dynamic checkbox based on object response,It should create multiple checkbox based on this response: test.json [ { "header":{ "serviceId":"inquiry-service", "productCode":"JPJXXX", "transactionId":"cfad2ac7c16XXX" }, "data":{ "items":[ { "offenceType4":"", "permSpeed":"110", "actSpeed":"123", "itemAttributes":{ "attribute5":"", "attribute4":"VQ3XXX", "attribute7":"14.21.00", "attribute6":"2018-03-22", "attribute1":"XXXXX", "attribute3":"XXXXXX", "attribute2":"XXXXXX" },

Add to the the beginning of Reactive Forms Array Angular

隐身守侯 提交于 2020-01-07 03:59:08
问题 Please see the relevant plunker https://plnkr.co/edit/f0BxpinhuqVz8o6IIFaL?p=preview // stack overflow makes you put code if a plunker is linked but it is too much code to copy paste here it would just look messy so I a am putting this comment instead. If you run this and then click the add button a new entry is added to the array, but the form view does not reflect the forms state, instead the first entry is duplicated and the last entry is gone. If anyone has any ideas or guides as to what

How to Update Values Dynamically for particular row in Table based on selection of one column?

亡梦爱人 提交于 2020-01-06 08:23:12
问题 I am using angular formarray to to iterate through the data. Table has 4 columns I want when I select a drop down in 3rd column data respective to that should get populate in 4th column. This is achieved, but when I try to select another drop down in the second row the the data gets wiped out for the first row as well. I need the data to be updated for that specific row only. Below it the formarray <tbody formArrayName="idsDetails" *ngFor="let idsDetail of boothData.get('idsDetails')[

Angular 5 - How to add Conditional Fields on Form Value Change

核能气质少年 提交于 2020-01-06 07:14:38
问题 I working on applying conditional field logic. Where two fields are dependant on their value. Requirement: Let's say, we've a radio button with following values: Do you want to format this code: o Yes o No If user selects, No, nothing happens. If user selects Yes, there would be another field which will as: Select formatting type: o HTML o PHP o Javascript I'm using https://toddmotto.com/angular-dynamic-components-forms way for generating form, where we pass the settings to FormGroup and it

Angular 5 | ReactiveForm with ControlValueAccessor | onChange is not triggered

*爱你&永不变心* 提交于 2020-01-06 06:01:31
问题 I have a custom ControlValueAccessor which simply appends a currency symbol on an input. @Component({ selector: 'app-currency-input', templateUrl: './currency-input.component.html', styleUrls: ['./currency-input.component.scss'], providers: [ CurrencyPipe, { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => CurrencyInputComponent), multi: true } ] }) export class CurrencyInputComponent implements ControlValueAccessor { @Input() class = ''; currencyValue: string; onChange: (value:

Store and Use Regex Const Validator in Angular 8 Reactive Formbuilder

拥有回忆 提交于 2020-01-05 07:13:36
问题 How do I store a Regex Validator pattern for reuse and Dry principal in Angular? Have a reactive formbuilder with Regex validator pattern below for ZipCode. Need to apply to multiple address forms, curious how to save /^\d{1,5}$/ So we can write Validators.pattern(zipcode) , or any syntax utilized in Angular? Company has more complicated long patterns for phone numbers, customer number, etc. 'ZipCode': [null, [Validators.maxLength(16), Validators.pattern(/^\d{1,5}$/)]], Looking for a way to

Store and Use Regex Const Validator in Angular 8 Reactive Formbuilder

馋奶兔 提交于 2020-01-05 07:13:08
问题 How do I store a Regex Validator pattern for reuse and Dry principal in Angular? Have a reactive formbuilder with Regex validator pattern below for ZipCode. Need to apply to multiple address forms, curious how to save /^\d{1,5}$/ So we can write Validators.pattern(zipcode) , or any syntax utilized in Angular? Company has more complicated long patterns for phone numbers, customer number, etc. 'ZipCode': [null, [Validators.maxLength(16), Validators.pattern(/^\d{1,5}$/)]], Looking for a way to

How to receive file upload from Angular Reactive Form?

岁酱吖の 提交于 2020-01-05 05:38:26
问题 I have module to upload file in Angular 7 Reactive Forms ( I need reactive form because I need to upload files and some other information together) I follow this article: https://medium.com/@amcdnl/file-uploads-with-angular-reactive-forms-960fd0b34cb5 the code as follow: https://pastebin.com/qsbPiJEX onFileChange(event) { const reader = new FileReader(); if(event.target.files && event.target.files.length) { const [file] = event.target.files; reader.readAsDataURL(file); reader.onload = () => {

How to add an undo button to a Reactive Form (Angular 2)?

末鹿安然 提交于 2020-01-04 04:07:14
问题 I have built a form using the Reactive Forms technique available in Angular 2. The form has many controls of different types. Now I need to add an undo button to it. I have been able to set up a basic undo button using the click and change events. I'm saving the previous value when someone clicks the form control and storing that value to Local Storage when the control's value is changed. However, this method has some drawbacks. For example, when someone tabs into the control, the click event