Skip to content

Commit

Permalink
Frontend_V2: Fix console error of change in expression value in devel…
Browse files Browse the repository at this point in the history
…opment setup(Cloud-CV#3550)

* fix change in expression value

* assign value on component initialization

* add line

Co-authored-by: Rishabh Jain <[email protected]>
  • Loading branch information
gautamjajoo and RishabhJain2018 authored Aug 26, 2021
1 parent c839e3d commit 9bcac47
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<app-side-bar *ngIf="authService.isAuth"></app-side-bar>
<app-side-bar *ngIf="isAuth"></app-side-bar>
<app-header-static></app-header-static>
<div class="web-container" [class.center]="!authService.isAuth">
<div class="web-container" [class.center]="!isAuth">
<div class="dashboard-flex">
<div class="dashboard-content">
<router-outlet></router-outlet>
</div>
<app-footer [isDash]="true" *ngIf="authService.isAuth"></app-footer>
<app-footer [isDash]="true" *ngIf="isAuth"></app-footer>
</div>
</div>
<div class="clearfix"></div>

<app-footer *ngIf="!authService.isAuth"></app-footer>
<app-footer *ngIf="!isAuth"></app-footer>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component } from '@angular/core';
import { Component, OnInit, AfterViewChecked, ChangeDetectorRef } from '@angular/core';
import { AuthService } from '../../services/auth.service';

/**
Expand All @@ -9,12 +9,36 @@ import { AuthService } from '../../services/auth.service';
templateUrl: './publiclists.component.html',
styleUrls: ['./publiclists.component.scss'],
})
export class PubliclistsComponent {
export class PubliclistsComponent implements OnInit, AfterViewChecked {

isAuth = false;

/**
* Constructor.
* @param authService
* @param changeDetector
*/
constructor(
public authService: AuthService
public authService: AuthService,
private cdRef : ChangeDetectorRef
) {}

/**
* Component on Initialization.
*/
ngOnInit() {
this.isAuth = this.authService.isAuth;
}

/**
* DEV MODE:
* For resolving change in expression value after it is checked
*/
ngAfterViewChecked() {
let isAuth = this.authService.isAuth;
if(isAuth != this.isAuth) {
this.isAuth = isAuth;
this.cdRef.detectChanges();
}
}
}

0 comments on commit 9bcac47

Please sign in to comment.