Login in angular 2
<p>I am an intern front-end developr, trying to make my way trough Angular 2. This project involves a simple login screen which I cannot get to work. I have tried various solutions to the problem but it simply does not work.
I keep on getting errors that I connot seem to get rid of. This time it's "Error during evaluation of 'submit'".
"Cannot read property 'post' of undefined. I worked on this problem for days and I am getting nowhere. Any help would be greatly appreciated...</p>

<p>I have a LoginService, a LoginComponent and a login.html</p>

<p>login.html:</p>

<pre><code>&lt;div id="login-container" class="center-block"&gt;
&lt;form role="form" (submit)="login($event, username.value, password.value)"&gt;
    &lt;div class="form-group text-left"&gt;
        &lt;label for="username"&gt;Username&lt;/label&gt;
        &lt;input type="text" 
        #username class="form-control" 
        id="username" 
        placeholder="Gebruikersnaam"&gt;
    &lt;/div&gt;
    &lt;div class="form-group text-left"&gt;
        &lt;label for="password"&gt;Password&lt;/label&gt;
        &lt;input type="password"
        #password class="form-control" 
        id="password" placeholder="Paswoord"&gt;
    &lt;/div&gt;
    &lt;div class="form-group text-left"&gt;
        &lt;input type="checkbox" id="login-remember"&gt;
        &lt;button type="submit" id="btn-login"
        class="btn btn-default"&gt;Submit&lt;/button&gt;
    &lt;/div&gt;
&lt;/form&gt;
&lt;/div&gt;
</code></pre>

<p>The loginComponent:</p>

<pre><code>import { Component, View, Inject } from 'angular2/core';
import {ROUTER_DIRECTIVES, Router, RouterLink, RouterOutlet } from 'angular2/router';
import { CORE_DIRECTIVES, FORM_DIRECTIVES } from 'angular2/common';
import { Http, Headers, contentHeaders } from 'angular2/http';
import {UserVM} from '../../interfaces/user';

@Component({
  selector: 'login',
  templateUrl: './app/templates/login.html',
  directives: [ROUTER_DIRECTIVES, RouterOutlet, RouterLink, CORE_DIRECTIVES],
  providers: [Http]

})
export class LoginCmp {
      login(event, username, password) {
    event.preventDefault();
    let body = JSON.stringify({ username, password });
    this.http.post('http://localhost:3000/sessions/create', body, { headers: contentHeaders })
      .subscribe(
        response =&gt; {
          localStorage.setItem('jwt', response.json().id_token);
          this.router.parent.navigateByUrl('/actuals');
        },
        error =&gt; {
          alert(error.text());
          console.log(error.text());
        }
      );
  }
}
</code></pre>

<p>The loginService:</p>

<pre><code>import { Component, View } from 'angular2/core';
import {RouteConfig, Router, RouterLink, RouterOutlet, Http} from 'angular2/router';
import { CORE_DIRECTIVES, FORM_DIRECTIVES } from 'angular2/common';
import { Http, Headers } from 'angular2/http';
import { contentHeaders } from '../common/headers';


export class LoginService {

  constructor(public router: Router, public http: Http) {
  }

  login(event, username, password) {
    event.preventDefault();
    let body = JSON.stringify({ username, password });
    this.http.post('http://localhost:3000/sessions/create', body, { headers: contentHeaders })
      .subscribe(
        response =&gt; {
          localStorage.setItem('jwt', response.json().id_token);
          this.router.parent.navigateByUrl('/actuals');
        },
        error =&gt; {
          alert(error.text());
          console.log(error.text());
        }
      );
  }
}
</code></pre>