We are going to continue with the job
module. The reason for this is that the company
module uses a component from the job
module in order to display a list of available jobs for a company.
The job service will handle communication with the backend, mostly for CRUD operations. We are going to create an Angular factory to accomplish this. Create a new file called public/app/job/job.service.js
and follow these steps:
Define the base structure and exposed methods:
import { Injectable } from 'angular2/core'; import { Http, Response, Headers } from 'angular2/http'; import { AuthHttp } from '../auth/index'; import { contentHeaders, serializeQuery } from '../common/index'; import { Job } from './job.model'; @Injectable() export class JobService { private _http: Http; private _authHttp: AuthHttp; constructor(http: Http, authHttp: AuthHttp) { this._http = http; this._authHttp = authHttp; } }
Implement the
create job
method:create(job) { let body ...