Skip to content

Instantly share code, notes, and snippets.

@rwherrmann
Created October 17, 2016 04:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rwherrmann/c7113c3cea44914c52ab0a0c41e83932 to your computer and use it in GitHub Desktop.
Save rwherrmann/c7113c3cea44914c52ab0a0c41e83932 to your computer and use it in GitHub Desktop.
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