concept app component in category nativescript

appears as: pp components, app component
NativeScript in Action

This is an excerpt from Manning's book NativeScript in Action.

The structure of a NativeScript app is important because NativeScript is an opinionated framework for developing mobile apps. Opinionated frameworks require you to write code, name files, and organize app components in certain ways; if you don’t follow the rules of NativeScript, your app won’t run. At this point, working with an opinionated framework probably sounds painful and frustrating. After all, why would you want to be restricted to following such specific rules? Don’t worry: I’ve got your back. NativeScript’s rules (also known as conventions) are easy to understand and make writing apps that work on Android and iOS simpler, not more complex. Let’s jump in and learn!

  • Step 3: Create a router outlet in the app component to manage control navigation
  • Step 4: Change the startup page to the app component
  • In the last chapter, you learned how to change the startup component by changing the value of the bootstrap component. Set the startup component to the app component, as shown in listing 16.11.

    Listing 16.11 The app.module.ts updated to load the app component as the startup component
    import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core"; import { NativeScriptModule } from "nativescript-angular/nativescript.module"; import { NativeScriptRouterModule } from "nativescript-angular/router"; import { routes, navigatableComponents } from "./app.routing"; import { AppComponent } from "./app.component"; import { HomeComponent } from "./views/home/home.component"; import { ListComponent } from "./views/list/list.component"; @NgModule({ declarations: [ AppComponent, ...navigatableComponents ], bootstrap: [ AppComponent #1 ], imports: [ NativeScriptModule, NativeScriptRouterModule, NativeScriptRouterModule.forRoot(routes) ], schemas: [NO_ERRORS_SCHEMA], }) export class AppModule { } #1 The bootstrap property controls the startup component
    Figure 16.10 The Pet Scrapbook after changing the startup component to the app component.