I am trying to set content type to json for my http post call in angular js 2 service. but it is not setting to the json causing getting null values in the api parameter
import {Injectable} from 'angular2/core';
import {Http} from 'angular2/http';
@Injectable()
export class DeviceService {
public headers: Headers;
constructor(private http:Http) {
this.headers = new Headers();
this.headers.append('Content-Type', 'application/json');
}
/*getAllUsers service to get data(users) from file or database*/
getDevice() {
return this.http.get('assets/api/device.json').map(
response => response.json()
);
}
save(model)
{
return this.http.post('http://localhost:14/someapi/method',
JSON.stringify(model),{headers: this.headers})
.map(response => response.json());
}
But when making post call it always show content type as 'text/plain;charset=UTF-8' in firebug console.