or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

bootstrap-platform.mddocument-management.mdevent-management.mdhydration.mdindex.mdsecurity-sanitization.mdtesting-debug.md
tile.json

bootstrap-platform.mddocs/

Bootstrap and Platform

Core functionality for initializing Angular applications in browser environments, supporting both traditional module-based and modern standalone application patterns with platform-specific services.

Capabilities

Application Bootstrap

Bootstrap standalone components as Angular applications with configurable providers and services.

/**
 * Bootstraps a standalone component as the application's root component
 * @param rootComponent - A reference to a standalone component that should be rendered
 * @param options - Extra configuration for the bootstrap operation
 * @returns A promise that returns an ApplicationRef instance once resolved
 */
function bootstrapApplication(
  rootComponent: Type<unknown>,
  options?: ApplicationConfig
): Promise<ApplicationRef>;

/**
 * Create an application instance without bootstrapping any components
 * @param options - Extra configuration for the application environment
 * @returns A promise that returns an ApplicationRef instance once resolved
 */
function createApplication(options?: ApplicationConfig): Promise<ApplicationRef>;

Usage Examples:

import { bootstrapApplication } from "@angular/platform-browser";
import { Component } from "@angular/core";

@Component({
  standalone: true,
  selector: 'app-root',
  template: '<h1>Hello World!</h1>'
})
class AppComponent {}

// Basic bootstrap
const appRef = await bootstrapApplication(AppComponent);

// Bootstrap with providers
await bootstrapApplication(AppComponent, {
  providers: [
    { provide: API_BASE_URL, useValue: 'https://api.example.com' },
    importProvidersFrom(SomeModule)
  ]
});

Platform Factory

Factory function for creating browser-specific platform instances with additional providers.

/**
 * A factory function that returns a PlatformRef instance associated with browser service providers
 * @param extraProviders - Optional additional providers to include
 * @returns PlatformRef instance configured for browser environment
 */
const platformBrowser: (extraProviders?: StaticProvider[]) => PlatformRef;

Usage Examples:

import { platformBrowser } from "@angular/platform-browser";
import { AppModule } from "./app/app.module";

// Basic platform bootstrap
const platform = platformBrowser();
const moduleRef = await platform.bootstrapModule(AppModule);

// Platform with extra providers
const platformWithProviders = platformBrowser([
  { provide: CUSTOM_SERVICE, useClass: CustomServiceImpl }
]);

Browser Module

NgModule that provides essential browser services and re-exports CommonModule and ApplicationModule.

/**
 * Exports required infrastructure for all Angular apps.
 * Included by default in all Angular apps created with the CLI.
 * Re-exports CommonModule and ApplicationModule, making their exports and providers available to all apps.
 */
class BrowserModule {
  constructor();
}

Usage Examples:

import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";

@NgModule({
  imports: [BrowserModule],
  declarations: [AppComponent],
  bootstrap: [AppComponent]
})
export class AppModule {}

// For feature modules, use CommonModule instead
@NgModule({
  imports: [CommonModule], // Not BrowserModule
  declarations: [FeatureComponent],
  exports: [FeatureComponent]
})
export class FeatureModule {}

Testing Support

Provides testability support for applications bootstrapped with standalone components, enabling Protractor and other testing tools.

/**
 * Returns a set of providers required to setup Testability for an application
 * bootstrapped using bootstrapApplication function
 * @returns An array of providers required to setup Testability for testing with Protractor
 */
function provideProtractorTestingSupport(): Provider[];

Usage Examples:

import { bootstrapApplication } from "@angular/platform-browser";
import { provideProtractorTestingSupport } from "@angular/platform-browser";

await bootstrapApplication(AppComponent, {
  providers: [
    provideProtractorTestingSupport(),
    // other providers
  ]
});

Types

/**
 * Set of config options available during the application bootstrap operation
 * @deprecated ApplicationConfig has moved, please import ApplicationConfig from @angular/core instead
 */
type ApplicationConfig = {
  providers?: Provider[];
};

/**
 * Injection token that controls whether styles of destroyed components should be removed from DOM
 * By default, the value is set to true
 */
const REMOVE_STYLES_ON_COMPONENT_DESTROY: InjectionToken<boolean>;