我试图在服务中使用Angular 2(2.0.0-rc.1)进行简单的Check Login方法.当我尝试将内容类型设置为application/json时,它在发送到我的web api后端时从不设置标题.
import { Injectable } from '@angular/core';
import { HTTP_PROVIDERS, Http, Response, Headers, RequestOptionsArgs, RequestMethod, Request, RequestOptions } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import { Other Modules Left out for Security } from 'Hidden';
@Injectable()
export class LoginService {
private _http: Http;
constructor(http: Http) {
this._http = http;
}
CheckLogin(model: CredentialModel) {
let url = 'http://localhost:51671/api/Login';
let data = JSON.stringify(model);
let headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('Accept', 'application/json');
let requestOptions = new RequestOptions({ …Run Code Online (Sandbox Code Playgroud)