Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.