How to set a default starting page in nativescript Angular

Issue

I built a nativescript project with tns create appname --template ng ,
it uses page-router-outlet,the nativescript docs say that the newest component is what starts up and I have page i want to start up first, is there anyway around this?

Solution

you should try changing default route to your desire component in app.routing.ts

for example:

try changing below code

const routes: Routes = [
    { path: "", redirectTo: "/items", pathMatch: "full" },
    { path: "items", component: ItemsComponent },
    { path: "item/:id", component: ItemDetailComponent },
];

To

const routes: Routes = [
    { path: "", redirectTo: "/yourcomponent", pathMatch: "full" },
    { path: "items", component: ItemsComponent },
    { path: "item/:id", component: ItemDetailComponent },
    { path: "yourcomponent", component: YourComponent },

];

Answered By – bhavin jalodara

Answer Checked By – Dawn Plyler (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.