Added observable handling for data in login page

This commit is contained in:
Lukas Metzger 2018-04-10 14:19:24 +02:00
parent d5be125982
commit 11416c682f
2 changed files with 10 additions and 7 deletions

View file

@ -5,7 +5,7 @@
<h3>Login</h3>
</div>
<div class="card-body">
<p *ngIf="isLogoutPage()" class="text-success">
<p *ngIf="isLogoutPage" class="text-success">
You have been successfully logged out.
</p>

View file

@ -1,4 +1,4 @@
import { Component } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { StateService } from '../../services/state.service';
@ -10,16 +10,23 @@ import { SessionOperation } from '../../operations/session.operation';
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss']
})
export class LoginComponent {
export class LoginComponent implements OnInit {
public loginForm: FormGroup;
public loginError = false;
public isLogoutPage = false;
constructor(private router: Router, private fb: FormBuilder, public gs: StateService,
private sessions: SessionOperation, private route: ActivatedRoute) {
this.createForm();
}
ngOnInit(): void {
this.route.data.subscribe((data) => this.isLogoutPage = data.logout);
}
private createForm() {
this.loginForm = this.fb.group({
username: ['', Validators.required],
@ -37,8 +44,4 @@ export class LoginComponent {
this.loginError = true;
}
}
public isLogoutPage() {
return this.route.snapshot.data.logout;
}
}