Angular 2 class without Http in the constructor parameters
<p>I have an API class:</p>

<pre><code>export class ApiService {

  constructor(public http: Http) { }

  put(controller: string, method: string, data: Object) {

    return this.http.put("http://127.0.0.1:8000",
      JSON.stringify(data), {
      })

    .map(res =&gt; res.json())

    .catch(err =&gt; {
      return Observable.throw(err.json());
    });

  }

}
</code></pre>

<p>and an AccountService class:</p>

<pre><code>export class AccountService {

  api: ApiService;

  constructor() {
    this.api = new ApiService();
  }

  login(username: string, password: string) {

    return this.api.put("accounts", "login", { username: username, password: password});

  }

}
</code></pre>

<p>However when I run this example there are two problems:</p>

<p>1) The <code>ApiService</code> needs http in the constructor. Therefore <code>this.api = new ApiService();</code> should provide <code>Http</code> which is not what I want.</p>

<p>How can I modify the <code>ApiService</code> so I don't have to provide <code>Http</code> to the constructor?</p>

<p>2) In the <code>AccountService</code> the <code>this.api.put</code> method is not found on the <code>ApiService</code>. Which I don't understand since I instantiated the <code>ApiService</code> into <code>this.api</code></p>