How to use the @angular/router.NavigationCancel function in @angular/router

To help you get started, we’ve selected a few @angular/router examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FINRAOS / herd-ui / src / testing / router-stubs.ts View on Github external
emitCancel(id: number = 1, url: string = 'testUrl.com/test', reason: string = 'Test Reason') {
    this.eventsSubject.next(new NavigationCancel(this.id, url, reason));
  }
  emitError(id: number = 1, url: string = 'testUrl.com/test', error: string = 'Test Error') {
github ionic-team / ionic / packages / angular / src / router / monkey-patch-router.ts View on Github external
(e: any) => {
          if (isNavigationCancelingError(e)) {
            router.navigated = true;
            router.resetStateAndUrl(storedState, storedUrl, rawUrl);
            (router.events as Subject)
                .next(new NavigationCancel(id, router.serializeUrl(url), e.message));

            resolvePromise(false);
          } else {
            router.resetStateAndUrl(storedState, storedUrl, rawUrl);
            (router.events as Subject)
                .next(new NavigationError(id, router.serializeUrl(url), e));
            try {
              resolvePromise(router.errorHandler(e));
            } catch (ee) {
              rejectPromise(ee);
            }
          }
        });
github gilsdav / ngx-translate-router / projects / ngx-translate-router / src / lib / localize-router.service.ts View on Github external
private cancelCurrentNavigation() {
    const currentNavigation = this.router.getCurrentNavigation();
    const url = this.router.serializeUrl(currentNavigation.extractedUrl);
    (this.router.events as Subject).next(new NavigationCancel(currentNavigation.id, url, ''));
    (this.router as any).transitions.next({...(this.router as any).transitions.getValue(), id: 0});
  }
github ionic-team / ionic / packages / angular / src / router / monkey-patch-router.ts View on Github external
() => {
          if (navigationIsSuccessful) {
            router.navigated = true;
            router.lastSuccessfulId = id;
            (router.events as Subject)
                .next(new NavigationEnd(
                    id, router.serializeUrl(url), router.serializeUrl(router.currentUrlTree)));
            resolvePromise(true);
          } else {
            router.resetUrlToCurrentUrlTree();
            (router.events as Subject)
                .next(new NavigationCancel(id, router.serializeUrl(url), ''));
            resolvePromise(false);
          }
        },
        (e: any) => {