Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {Component} from "@angular/core";
- import {LoginService} from "./login.service";
- import {Router} from "@angular/router";
- @Component({
- selector: 'login',
- templateUrl: 'app/user/login.component.html'
- })
- export class LoginComponent {
- username: string = 'admin';
- password: string = 'admin';
- constructor(private userService: LoginService, private router: Router) { }
- onLogin() {
- this.userService.login(this.username, this.password).subscribe((result) => {
- console.log("LOGIN: " +result);
- if(result) {
- console.log("YESI");
- this.router.navigate(['home']);
- }
- })
- }
- onLogout() {
- this.userService.logout().subscribe((result) => {
- console.log("LOGOUT: " +result);
- if(!result) {
- console.log("YESO");
- this.router.navigate(['home']);
- }
- })
- }
- isAuthenticated() {
- return !!this.userService.isLoggedIn();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement