troubleshooting Question

Passing client data from form to server

Avatar of zolf
zolfFlag for United Arab Emirates asked on
JSONWeb Languages and Standards* HTML 5Web Development
4 Comments1 Solution228 ViewsLast Modified:
Hello there,

I have a HTML5 form with Angular 2 and I have a form that takes string and integer value and sends it to my Java backend server. But for some reason my integer value is being sent as string in the JSON which passes to the server. Below is the code. I will appreciate your help!


<div class="form-group row">
                <label class="col-form-label col-md-4" for="fax">Fax <span class="required">*</span></label>
                  <div class="col-md-7">
                    <input class="form-control" 
                                    formControlName="fax" />

            name_en: this.companyProfile.name_en,
            address: this.companyProfile.address,
            fax: this.companyProfile.fax,

saveCompanyProfile(): void {
        if (this.companyForm.dirty && this.companyForm.valid) {
            // Copy the form values over the CompanyProfile object values
            console.log("  ZZZZZZZZ    "+JSON.stringify(this.companyForm.value));
            let p = Object.assign({}, this.companyProfile, this.companyForm.value);

                    () => this.onCompanyProfileComplete(),
                    (error: any) => this.errorMessage = <any>error
        } else if (!this.companyForm.dirty) {

and my Service class that talks to the server looks like so,

private updateCompanyProfile(companyprofile: ICompanyProfile, options: RequestOptions): Observable<ICompanyProfile> {
        const url = `${this.referenceUrl}/${companyprofile.name_en}`;
        console.log('url: ' + url)
        console.log('updateCompanyProfile: ' + JSON.stringify(companyprofile))
        return this.http.put(url, companyprofile, options)
            .map(() => companyprofile)
            .do(data => console.log('update companyprofile: ' + JSON.stringify(data)))
Jim Riddles
Prepress/OMS Specialist

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros