title: angular 2 http post issue
body: <p>i am getting   error , when i am trying to sent post request to my server <br> how to solve this ?</p>
  
  <p><strong>error</strong></p>
  
  <blockquote>
    <p>XMLHttpRequest cannot load <a href="http://localhost/posttest.php" rel="nofollow noreferrer">http://localhost/posttest.php</a>. Request
    header field Content-Type is not allowed by
    Access-Control-Allow-Headers in preflight response.</p>
  </blockquote>
  
  <p><strong>php code</strong>
   <a href="http://localhost/posttest.php" rel="nofollow noreferrer">http://localhost/posttest.php</a></p>
  
  <pre><code>header("Access-Control-Allow-Origin: *");&lt;br&gt;
  $data = array("token"=&gt;"","l_date"=&gt;"");&lt;br&gt;
  $data_json = json_encode($data);&lt;br&gt;
  echo $data_json;
  </code></pre>
  
  <p><strong>angular 2 http post code</strong></p>
  
  <pre><code>import {Injectable} from '@angular/core';
  import { Http, RequestOptions,Headers,Response } from '@angular/http';
  import 'rxjs/add/operator/map'; 
  
  @Injectable()
  export class PostsService{
  constructor(private http:Http){
      console.log("post service initialized ... ");
  
  }
  getPosts(id:number){
      return this.http.get('https://jsonplaceholder.typicode.com/posts/'+id).map(res=&gt;res.json());
  }
  postexample(){
      var json=JSON.stringify({milla:"hi",login2:"milla"});
      var param="json="+json;
      let headers1 = new Headers({ 'Accept': 'application/json','Content-Type': 'application/json' });
      let options = new RequestOptions({ headers: headers1 });
      let body = JSON.stringify(json);
      return this.http.post('http://localhost/posttest.php', body, options ).map((res: Response) =&gt; res.json());
  }
  }
  </code></pre>