37 lines
918 B
TypeScript
37 lines
918 B
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { FormControl, FormGroup } from '@angular/forms';
|
|
import { AccountService } from '../account.service';
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
|
|
|
@Component({
|
|
selector: 'app-login',
|
|
templateUrl: './login.component.html',
|
|
styleUrls: ['./login.component.css']
|
|
})
|
|
export class LoginComponent implements OnInit {
|
|
form: FormGroup = new FormGroup({
|
|
username: new FormControl(''),
|
|
password: new FormControl(''),
|
|
});
|
|
loading = false;
|
|
returnUrl = this.activatedRoute.snapshot.queryParams['returnUrl'] || '/';
|
|
|
|
onLogin() {
|
|
this.loading = true;
|
|
if (this.form.invalid) {
|
|
return;
|
|
}
|
|
console.log(this.form.value);
|
|
|
|
}
|
|
|
|
constructor(private accountService: AccountService,
|
|
private activatedRoute: ActivatedRoute,
|
|
private router: Router,
|
|
) { }
|
|
|
|
ngOnInit(): void {
|
|
}
|
|
|
|
}
|