How to set value for dynamically generated form using angular 4


How to set value for dynamically generated form using angular 4



I have angular 4 form which is generated dynamically using the configuration(JSON) file. And i want to set the value for input field while choosing the selectbox option.



I have created the sample code in stackblitz.


stackblitz



https://stackblitz.com/edit/angular-dnhcd1?file=src/app/dynamic-form-component.ts





You can format the FormGroup using a setter in @ Input angular.io/guide/…
– Eliseo
Jul 3 at 6:27




1 Answer
1



I have found a solution to set the value.


this.issuerConfigForm.controls['iinprefix'].patchValue("20");





Use setValue, not patchValue
– Envil
Jul 3 at 4:35


setValue


patchValue





@Envil setValue is used for to set the value of all fields of form and patchValue is used for to set the value of specific field in form. Here vishnu just wanted to set the value of one field
– Parth Savadiya
Jul 3 at 4:47





@ParthSavadiya is it? toddmotto.com/angular-2-form-controls-patch-value-set-value
– Envil
Jul 3 at 4:58






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

api-platform.com Unable to generate an IRI for the item of type

How to set up datasource with Spring for HikariCP?

Display dokan vendor name on Woocommerce single product pages