How to change value of object of type FormGroup from class file i.e. typescript file

I’m new to ionic 2. I don’t know how to access and change the values that are getting submitted with this FormGroup object. I need to change some of the values from this object before call to API.

 export class MePage {
    	reqObject: FormGroup;
    	constructor(public formBuilder: FormBuilder) {}
    	ionViewDidLoad() {
    		this.reqObject = this.formBuilder.group({
    			userField: ['some value']
    		})
    	}
    	// Thats all I got and it is working fine but now i need to change the value of 'userField' in any method like bellow
    	changeValue() {
    		this.reqObject.userField = "some changed value"
    		// This i need to do.
    	}
    }

Please help me out, thanks in advance

Simply take a look in the anuglar2 documention for ReactiveForms… there you will find out, that there are special methods to get access to a FormControl of a FormGroup and special methods to manipulate control values:

https://angular.io/docs/ts/latest/api/forms/index/FormGroup-class.html#!#setValue-anchor

1 Like

Thank you very much for your instant and very very helpful support

I’m able to do it now, and i also got some more important methods over there.
Thank you very much.

1 Like