diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 5c3b899..ab60884 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,4 +1,4 @@ -import {ChangeDetectorRef, Component} from '@angular/core'; +import {ChangeDetectorRef, Component, OnDestroy, OnInit} from '@angular/core'; import {ActivatedRoute, NavigationEnd, Router} from '@angular/router'; import {EnvProperties} from './openaireLibrary/utils/properties/env-properties'; @@ -7,16 +7,18 @@ import {User} from './openaireLibrary/login/utils/helper.class'; import {UserManagementService} from "./openaireLibrary/services/user-management.service"; import {SideBarService} from "./library/sharedComponents/sidebar/sideBar.service"; import {StakeholderService} from "./services/stakeholder.service"; +import {Subscriber} from "rxjs"; @Component({ selector: 'app-root', templateUrl: './app.component.html' }) -export class AppComponent { +export class AppComponent implements OnInit, OnDestroy{ properties: EnvProperties; user: User; loginCheck: boolean = false; hasSidebar: boolean = false; + public subscriptions: any[] = []; constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService, @@ -60,9 +62,17 @@ export class AppComponent { console.log(error); }); }); - this.sidebarService.hasSidebar.subscribe(hasSidebar => { + this.subscriptions.push(this.sidebarService.hasSidebar.subscribe(hasSidebar => { this.hasSidebar = hasSidebar; this.cdr.detectChanges(); + })); + } + + public ngOnDestroy() { + this.subscriptions.forEach( value => { + if(value instanceof Subscriber) { + value.unsubscribe(); + } }); } @@ -70,7 +80,6 @@ export class AppComponent { return this.sidebarService.open; } - public toggleOpen(event = null) { if(!event) { this.sidebarService.setOpen(!this.open); diff --git a/src/app/home/home.component.html b/src/app/home/home.component.html index 766a87a..f4f38b9 100644 --- a/src/app/home/home.component.html +++ b/src/app/home/home.component.html @@ -10,7 +10,6 @@