Created
October 17, 2016 04:37
-
-
Save rwherrmann/c7113c3cea44914c52ab0a0c41e83932 to your computer and use it in GitHub Desktop.
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
import { Component, OnInit } from '@angular/core'; | |
import { Router } from '@angular/router'; | |
import { UserService } from '../services/user.service'; | |
@Component({ | |
selector: 'app-login', | |
templateUrl: './login.component.html', | |
styleUrls: ['./login.component.less'] | |
}) | |
export class LoginComponent implements OnInit { | |
login = { | |
username: '', | |
password: '' | |
}; | |
showErrorMessage = false; | |
constructor(private router: Router, private userService: UserService) { } | |
ngOnInit() { | |
} | |
authenticateUser() { | |
this.userService.login(this.login.username, this.login.password) | |
.subscribe((result) => { | |
if (result) { | |
this.router.navigateByUrl('/dashboard/home'); | |
} else { | |
this.showErrorMessage = true; | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment