File

src/app/modules/public/services/pending-changes-guard/pendingchanges.guard.ts

Index

Properties
Methods

Constructor

constructor(resourceService: ResourceService)
Parameters :
Name Type Optional
resourceService ResourceService No

Methods

canDeactivate
canDeactivate(component: ComponentCanDeactivate)
Parameters :
Name Type Optional
component ComponentCanDeactivate No
Returns : boolean | Observable
import { CanDeactivate } from '@angular/router';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { ResourceService } from '@sunbird/shared';

export interface ComponentCanDeactivate {
  canDeactivate: () => boolean | Observable<boolean>;
}

@Injectable()
export class PendingchangesGuard implements CanDeactivate<ComponentCanDeactivate> {
  constructor(public resourceService: ResourceService) { }
  canDeactivate(component: ComponentCanDeactivate): boolean | Observable<boolean> {
    return component.canDeactivate() ?
      true :
      confirm(this.resourceService.frmelmnts.lbl.leavePage);
  }
}

results matching ""

    No results matching ""