File

src/app/modules/public/services/landingpage-guard/landingpage.guard.ts

Index

Methods

Constructor

constructor(router: Router)
Parameters :
Name Type Optional
router Router No

Methods

canActivate
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot)
Parameters :
Name Type Optional
next ActivatedRouteSnapshot No
state RouterStateSnapshot No
Returns : Observable | Promise | boolean
import { Injectable } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router';
import { Observable } from 'rxjs';
import { environment } from '@sunbird/environment';
@Injectable()
export class LandingpageGuard implements CanActivate {
  constructor(private router: Router) { }
  canActivate(
    next: ActivatedRouteSnapshot,
    state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
      if (environment.isDesktopApp) {
        this.router.navigate(['/mydownloads'], { queryParams: { selectedTab: 'mydownloads' }});
        return false;
      } else {
        const defaultTenantIndexStatus: string = (<HTMLInputElement>document.getElementById('defaultTenantIndexStatus')) ?
        (<HTMLInputElement>document.getElementById('defaultTenantIndexStatus')).value : 'false';
        if (defaultTenantIndexStatus.toLowerCase() === 'true') {
          window.location.replace(window.location.origin);
        }
        return (defaultTenantIndexStatus.toLowerCase() !== 'true');
      }
  }
}

results matching ""

    No results matching ""