liveBook · Manning

bootstrapApplication

As explained in Modern Angular

bootstrapApplication is an Angular function that creates and bootstraps an application from a root component and optional application configuration.

bootstrapApplication is the modern Angular entry point for creating an application from one root component and optional application configuration. It replaces platformBrowserDynamic().bootstrapModule(AppModule), allowing standalone applications to initialize without an NgModule. section 1.3.3

The application configuration carries dependency-injection providers through ApplicationConfig. Routing moves from RouterModule.forRoot(routes) to provideRouter(routes), while main.ts directly bootstraps AppComponent. section 1.3.3

Standalone HRMS entry point

A generated HRMS project can keep configuration in app/app.config.ts and start from main.ts: import { bootstrapApplication } from '@angular/platform-browser'; import { appConfig } from './app/app.config'; import { AppComponent } from './app/app.component'; bootstrapApplication(AppComponent, appConfig).catch((err) => console.error(err)); The root component is standalone, and appConfig can provide routing with provideRouter(routes). section 1.3.3

Migrate a legacy NgModule application incrementally:

  • Run ng g @angular/core:standalone on Angular v16 and choose “Convert all components, directives, and pipes to standalone.” section 2.5.3
  • Run the schematic again to remove unnecessary NgModule classes, testing the application after each conversion. section 2.5.3
  • Run “Bootstrap the Application Using Standalone APIs” to remove AppModule and switch main.ts to bootstrapApplication. section 2.5.3
  • Inspect remaining NgModules, standalone routing, and third-party dependencies that may still use importProvidersFrom. section 2.5.3
. 
└── hrms/
    └── src/
        ├── app/
        │   ├── app.component.css
        │   ├── app.component.html
        │   ├── app.component.spec.ts
        │   ├── app.component.ts
        │   ├── app.config.ts
        │   └── app.routes.ts
        ├── assets/
        ├── index.html
        ├── main.ts
        └── styles.css

Browse the standalone project structure locating main.ts, app.config.ts, app.routes.ts, and the root component files. section 1.3.3

How Modern Angular covers it

How deep it goes
Explains the entry-point replacement, configuration role, routing integration, and migration steps without covering runtime internals.
Examples
Uses an HRMS project with main.ts, AppComponent, app.config.ts, app.routes.ts, and a standalone migration command.
What it assumes
Assumes familiarity with Angular components, routing, dependency injection, and NgModules while showing the new bootstrap arrangement.
What you can do after
Operate/configure a standalone Angular entry point and migrate an NgModule bootstrap using the Angular standalone schematic.
How it connects
Connects standalone components, ApplicationConfig, dependency injection, routing, and NgModules.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern Angular. The section links point to the parts of the book it draws on.