nativescript-angular icon indicating copy to clipboard operation
nativescript-angular copied to clipboard

Feature Request: Support for replaceUrl and skipLocationChange

Open chimon2000 opened this issue 8 years ago • 21 comments

The options for replaceUrl and skipLocationChange are available in the router's ExtendedNavigationExtras, but they are not being implemented in the PageRouterOutlet. When you try to use either of them

this.routerExtensions.navigate(["/tab"], { replaceUrl: true }) 
//OR
this.routerExtensions.navigate(["/tab"], { skipLocationChange: true })

Navigation fails to skip the a page in the stack, and navigates back to the page that the application was on.

These features would be nice for when an application wants to route to a new page while removing part of the router location history.

chimon2000 avatar Mar 16 '17 20:03 chimon2000

+1 Hopefully this really gets done in 3.2 and the 3.2 release isn't too far away!

This seems to be the only way to successfully add an interstitial login page that doesn't get added to History. For example:

  • Home page that does not require login
  • Routing for nested page: { path: "foo", component: FooComponent, canActivate: [AuthGuard] }
  • AuthGuard:
  canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
    if (LoginService.isLoggedIn()) {
      return true;
    } else {
      this.redirectUrl = state.url;
      this.router.navigate(["/login"], { skipLocationChange: true });
      return false;
    }
  }

and redirect code once login is successful:

    this.router.navigate([this.redirectUrl]);

Issue #284 suggests to use a modal dialog, but I don't think I can do that in this scenario: the AuthGuard can't display it and there are 4 or 5 pages I want to protect with login, so implementing it for each page is untenable.

RobertGardner avatar Jun 27 '17 02:06 RobertGardner

Hi there. I was looking for 3.2 release to fix this feature, but as I see it is not there. Do you have any info when can this be implemented? Or is it any workaround?

MartinMitro avatar Sep 12 '17 12:09 MartinMitro

Hi, Any updates on this features?

mayureshjadhav avatar Nov 24 '17 05:11 mayureshjadhav

any updates guys?

ptdede avatar Feb 14 '18 07:02 ptdede

any updates on skipLocationChange?

bhavincb avatar Mar 16 '18 21:03 bhavincb

+1

anuragd7 avatar Mar 21 '18 10:03 anuragd7

+1

Ross-Jo avatar Jun 18 '18 10:06 Ross-Jo

Anybody know any workarounds?

EDIT - not exactly what this feature request is asking for, but for those searching on Google:

import { RouterExtensions } from 'nativescript-angular/router';

...

this.router.navigate(['/somewhere'], { clearHistory: true }); // remove history after navigating

neil-119 avatar Jul 06 '18 17:07 neil-119

+1

neillin avatar Jul 15 '18 15:07 neillin

+1

yonatann avatar Dec 03 '18 21:12 yonatann

+1

rickwalking avatar Aug 01 '19 18:08 rickwalking

+1

ErikWitkowski avatar Aug 15 '19 13:08 ErikWitkowski

+1

daweedm avatar Aug 16 '19 23:08 daweedm

+1

HazizKhan avatar Dec 18 '19 15:12 HazizKhan

+1

sabasanu avatar Jan 21 '20 14:01 sabasanu

+1

mehtmehtsen avatar Feb 10 '20 14:02 mehtmehtsen

Would love to see support for this.

MitchTalmadge avatar Apr 03 '20 08:04 MitchTalmadge

+1

miladfm avatar Dec 28 '20 13:12 miladfm

any updates regarding this feature request? the use case would be important for us and I don't see a good workaround for this yet

mwagnurr avatar Aug 02 '21 13:08 mwagnurr

+1000000000

So excited got the new release of N8 with A12, but not without this features yet!

jajatismail avatar Sep 09 '21 08:09 jajatismail

+1

justintoth avatar Dec 17 '21 01:12 justintoth