Cookies concent notice

This site uses cookies from Google to deliver its services and to analyze traffic.
Learn more
Skip to main content
This site is no longer updated.Head to Angular.devHome
/

This is the archived documentation for Angular v17. Please visit angular.dev to see this page for the current version of Angular.

APP_ID

A DI token representing a string ID, used primarily for prefixing application attributes and CSS styles when ViewEncapsulation#Emulated is being used.

See more...

      
      const APP_ID: InjectionToken<string>;
    

Description

The token is needed in cases when multiple applications are bootstrapped on a page (for example, using bootstrapApplication calls). In this case, ensure that those applications have different APP_ID value setup. For example:

      
      bootstrapApplication(ComponentA, {
  providers: [
    { provide: APP_ID, useValue: 'app-a' },
    // ... other providers ...
  ]
});

bootstrapApplication(ComponentB, {
  providers: [
    { provide: APP_ID, useValue: 'app-b' },
    // ... other providers ...
  ]
});
    

By default, when there is only one application bootstrapped, you don't need to provide the APP_ID token (the ng will be used as an app ID).