From 11416c682f932f20087e98645350cb4eb1a14cef Mon Sep 17 00:00:00 2001 From: Lukas Metzger Date: Tue, 10 Apr 2018 14:19:24 +0200 Subject: [PATCH] Added observable handling for data in login page --- frontend/src/app/pages/login/login.component.html | 2 +- frontend/src/app/pages/login/login.component.ts | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/frontend/src/app/pages/login/login.component.html b/frontend/src/app/pages/login/login.component.html index b201063..2670023 100644 --- a/frontend/src/app/pages/login/login.component.html +++ b/frontend/src/app/pages/login/login.component.html @@ -5,7 +5,7 @@

Login

-

+

You have been successfully logged out.

diff --git a/frontend/src/app/pages/login/login.component.ts b/frontend/src/app/pages/login/login.component.ts index 40886ce..c484bed 100644 --- a/frontend/src/app/pages/login/login.component.ts +++ b/frontend/src/app/pages/login/login.component.ts @@ -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; - } }