Is recursive Navigation to the same page possible?


#1

Hi,

Does anyone know if it’s possible to navigate to the same page with a different parameter, and actually have the mobile devices navigation controller see it as an actual page navigation, with animation, new component creation and an additional item in the history to go back? I’m essentially looking for a way to push a new page onto the stack even if it’s the exact same page with new parameters.

In previous mobile apps we’ve written in Swift and Xamarin, we’ve had to use recursive navigation to drill into hierarchies of data, which i am looking to reproduce. However with Angular’s routing system, if you navigate to the same route again with a new parameter, it doesn’t actually navigate anywhere. It also doesn’t call ngOnInit again, it just re-uses the existing component that has been created. I know you can subscribe to the route.params data using ActivatedRoute to detect when a new param has been given, so I can load fresh data for the component using that, however because it’s not actually navigated anywhere, pressing the back button simply goes back to the very first page. Because it’s not pushed a new page onto the navigation stack, you can’t navigate back.

Is there any way around this? Or is recursive navigation a concept that’s simply not possible with NativeScript/Angular?

Here’s the versions of packages I am using

“nativescript”: {
“id”: “com.xxx.xxxxxxxx”,
“tns-ios”: {
“version”: “3.0.0”
},
“tns-android”: {
“version”: “3.0.0”
}
},
“dependencies”: {
"@angular/animations": “~4.1.0”,
"@angular/common": “~4.1.0”,
"@angular/compiler": “~4.1.0”,
"@angular/core": “~4.1.0”,
"@angular/forms": “~4.1.0”,
"@angular/http": “~4.1.0”,
"@angular/platform-browser": “~4.1.0”,
"@angular/router": “~4.1.0”,
“nativescript-angular”: “~3.0.0”,
“nativescript-theme-core”: “~1.0.2”,
“reflect-metadata”: “~0.1.8”,
“rxjs”: “~5.3.0”,
“tns-core-modules”: “~3.0.0”,
“zone.js”: “~0.8.2”
}

Thanks


#2

I am also facing same issue. Any solution plz?


#3

Well a solution to the problem would be to create a new page with exactly the same things and you just add the new items, it would work but i dont think it is the best approach since its going to become repetitive code and we should avoid that.