Last active
June 25, 2016 09:13
-
-
Save sonicoder86/bbaff08be197988813ce953e1e1140f2 to your computer and use it in GitHub Desktop.
Authentication in Angular 2 - part 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// login.component.ts | |
import { Component } from '@angular/core'; | |
import { Router } from '@angular/router-deprecated'; | |
import { UserService } from './user.service'; | |
@Component({ | |
selector: 'login', | |
template: `...` | |
}) | |
export class LoginComponent { | |
constructor(private userService: UserService, private router: Router) {} | |
onSubmit(email, password) { | |
this.userService.login(email, password).subscribe((result) => { | |
if (result) { | |
this.router.navigate(['Home']); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment