down votefavorite 
<http://stackoverflow.com/questions/40756673/post-data-in-angular2#>

I am facing the issue of json  being added to the url after calling the 
service to add the data.

below is my file

JobBookingComponent.ts

CreateNew(): void {
  this.router.navigate(['/detail', 0]);}

JobDetailsComponent.ts

Submit() {
    let templateId;
    this.route.params.subscribe(
        (param: any) => {
            templateId = +param['templateid']; });
    if (templateId === 0) {
        this.jobservice.addJob(this.job).subscribe(error => this.errorMessage = 
<any>error);
    }
    this.router.navigate(['/template']);}

service.ts

addJob(job: Job): Observable <Job> {

    let headers = new Headers({ 'Content-Type': 'application/json' });
    let options = new RequestOptions({ headers: headers });
    console.log(job);
    return this.http.post('http://localhost:51293/api/JobBooking/AddProduct', 
JSON.stringify(job), options).map(this.extractData).catch(this.handleError);}

I am not able to find the issue why it is adding the json data to the url 
and i am getting error.

The url becomes 
http://localhost:51293/template?templateid=0&templatename=&product=NA&producttype=sad&movementtype=CY+to+CY&IncoTerms=&IncoTermLoc=&Shipper=&OriginBrnach=&PlaceOfRecipt=&CargoAvailable=&OrgClearanceBy=&OrgClearanceName=&Consignee=&DestinationBrnach=&AgilityPlaceOfDelivery=&CargoDelDtFrom=&DesClearanceBy=&DesClearanceName=&CustomerReqBLType=&DocumentType=&MBLType=&MBLterms=


Routes.ts

import { NgModule } from '@angular/core';

import { Routes, RouterModule } from '@angular/router';


import { JobBookingComponent } from './component/jobbooking';

import { JobDetailsComponent } from 
'./component/jobbookingdetailscomponent';

import { JPTemplateComponent } from './component/jptemplate.component';



const routes: Routes = [

    { path: '', redirectTo: '/templatejp', pathMatch: 'full' },

    

    { path: 'template', component: JobBookingComponent },

    { path: 'templatejp', component: JPTemplateComponent },

    { path: 'detail/:templateid', component: JobDetailsComponent }

    

];


@NgModule({

    imports: [RouterModule.forRoot(routes)],

    exports: [RouterModule]

})

export class AppRoutingModule { }

-- 
You received this message because you are subscribed to the Google Groups 
"Angular" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to