Search code examples
angularnativescriptnativescript-angular

How to set a default starting page in nativescript Angular


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 },
    
    ];