Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import { Component, OnInit } from '@angular/core';
  2.  
  3. import { AuthenticationService } from '../authentication.service';
  4.  
  5. @Component({
  6. selector: 'app-login',
  7. templateUrl: './login.component.html',
  8. styleUrls: ['./login.component.css'],
  9. providers: [AuthenticationService]
  10. })
  11. export class LoginComponent implements OnInit {
  12.  
  13. credentials: {
  14. username: '',
  15. password: ''
  16. };
  17.  
  18. constructor(private _authenticationService: AuthenticationService) {}
  19.  
  20. ngOnInit() { }
  21.  
  22. login() {
  23.  
  24. this._authenticationService.login(this.credentials).subscribe(
  25. response => console.log(response),
  26. error => console.log(error),
  27. () => console.log('Done.')
  28. );
  29.  
  30. }
  31.  
  32. import { Http } from '@angular/http';
  33. import { Injectable } from '@angular/core';
  34.  
  35. @Injectable()
  36. export class AuthenticationService {
  37.  
  38. constructor() { }
  39.  
  40. login(credentials) {
  41.  
  42. console.log(credentials); // This is undefined
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement