Passing objects while navigating in Angular + NativeScript is not the same as vanila NativeScript. The routing is entirely implemented via angular specifications which means you will need to use their implementation. The current RC5 version of Angular 2 uses the following navigation (routing). You need to create a RouterConfig with all of the possible app routes for example:
const ROUTES: RouterConfig = [
{ path: "", redirectTo: "/home-page", terminal: true },
{ path: "home=page", component: HomePageComponent },
{ path: "second-page", component: SecondPageComponent }
];
You can also make use of parameterized routes and pass some simple string arguments, imagine the URI in a web site page. By doing this you can for example pass some sort of "crippled" string that will help you retrieved the required information by the page you are navigation to. After that in your second page you can subscribe to the ActivatedRoute and retrieve those arguments. Here is an example of that:
the routes:
import { RouterConfig } from '@angular/router';
const ROUTES: RouterConfig = [
{ path: "", redirectTo: "/home-page", terminal: true },
{ path: "home=page", component: HomePageComponent },
{ path: "second-page/:firstArg/:secondArg", component: SecondPageComponent }
];
and the SecondPageComponent:
import { Component, OnInit } from "@angular/core";
import { ActivatedRoute, Router } from '@angular/router';
@Component({
moduleId: module.id,
selector: "second-page",
templateUrl: "second-page.component.html",
styleUrls: ["second-page.component.css"]
})
export class SecondPageComponent implements OnInit {
constructor(private _router: Router, private _route: ActivatedRoute) {
}
ngOnInit() {
this._sub = this._route.params.subscribe(params => {
var parentTitle = params['parentTitle'];
var tappedTitle = params['tappedTitle'];
this.hasBack = false;
this._currentExample = this._exampleItemsService.getParentExampleItem(0);
});
}
You can take a look at the nativescript-ui-samples-angular github repo that showcases such navigation and interesting examples. In order to run that repo's {N} project you will need either the free plugin or the pro one.
app.routeslook like?app.modulesand the component this is happening in?HTTPrequest and to get the other data or to use global variable in your project to access theJSONfrom both pages. you could also review my sample project here. - github.com/tsonevn/NGNavClearHistory/tree/navigate_with_params