Skip to content

Instantly share code, notes, and snippets.

@hamedbaatour
Created August 6, 2019 08:41
Show Gist options
  • Save hamedbaatour/0395dae795690de914716d8340a0fcc0 to your computer and use it in GitHub Desktop.
Save hamedbaatour/0395dae795690de914716d8340a0fcc0 to your computer and use it in GitHub Desktop.
import {Component, OnInit} from '@angular/core';
import {FbService} from '../../services/fb/fb.service';
import {first, tap} from 'rxjs/operators';
import {Router} from '@angular/router';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {
errorMessage = '';
constructor(public fb: FbService, public router: Router) {
}
ngOnInit() {
}
login(e) {
this.fb.signin(e.target.email.value, e.target.password.value).pipe(first()).subscribe(() => {
this.router.navigateByUrl('');
},(err) => {
this.errorMessage = err;
setTimeout(() => this.errorMessage = '', 2000);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment