Skip to content

Instantly share code, notes, and snippets.

@4skinSkywalker
Last active March 28, 2019 15:14
Show Gist options
  • Select an option

  • Save 4skinSkywalker/302f29e39bed2ac2c47539dc015f0a3d to your computer and use it in GitHub Desktop.

Select an option

Save 4skinSkywalker/302f29e39bed2ac2c47539dc015f0a3d to your computer and use it in GitHub Desktop.
import { Component, OnInit } from '@angular/core'
import { AuthService } from '../services/auth.service'
import { Router } from '@angular/router'
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {
isInvalid: boolean = false
constructor(
private authService: AuthService,
private router: Router) { }
ngOnInit() {
}
submit(f) {
const credentials = f.value
this.authService.login(credentials)
.subscribe(result => {
this.router.navigate([''])
},
error => {
if (error === 'Unauthorized.') {
this.isInvalid = true
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment