Skip to content

Instantly share code, notes, and snippets.

@sonicoder86
Last active June 25, 2016 09:13
Show Gist options
  • Save sonicoder86/bbaff08be197988813ce953e1e1140f2 to your computer and use it in GitHub Desktop.
Save sonicoder86/bbaff08be197988813ce953e1e1140f2 to your computer and use it in GitHub Desktop.
Authentication in Angular 2 - part 3
// 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