Complete the code to bootstrap an Angular standalone component.
import { bootstrapApplication } from '@angular/platform-browser'; import { AppComponent } from './app.component'; bootstrapApplication([1]);
NgModule which is not needed for standalone bootstrapping.The bootstrapApplication function takes the standalone component to start the app. Here, AppComponent is the standalone component.
Complete the code to add a provider when bootstrapping a standalone component.
bootstrapApplication(AppComponent, {
providers: [[1]]
});HttpClientModule directly in providers.Providers are added as objects describing the service. Here, an HTTP interceptor is provided correctly.
Fix the error in bootstrapping by completing the missing import.
import { bootstrapApplication } from '@angular/platform-browser'; import { AppComponent } from './app.component'; import { importProvidersFrom } from '@angular/core'; import { [1] } from '@angular/common/http'; bootstrapApplication(AppComponent, { providers: [importProvidersFrom(HttpClientModule)] });
HttpClient instead of HttpClientModule.The HttpClientModule must be imported from @angular/common/http and used with importProvidersFrom to provide HTTP services in standalone bootstrapping.
Complete the blank to correctly bootstrap a standalone component with routing.
import { bootstrapApplication } from '@angular/platform-browser'; import { AppComponent } from './app.component'; import { [1] } from '@angular/router'; bootstrapApplication(AppComponent, { providers: [[1]([])] });
RouterModule directly in providers without wrapping.Routes type with provider functions.To add routing providers in standalone bootstrapping, import and use provideRouter([]) in the providers array.
Fill all three blanks to bootstrap a standalone component with HTTP and routing providers.
import { bootstrapApplication } from '@angular/platform-browser'; import { AppComponent } from './app.component'; import { [1] } from '@angular/common/http'; import { [2] } from '@angular/router'; import { [3] } from '@angular/core'; bootstrapApplication(AppComponent, { providers: [ importProvidersFrom(HttpClientModule), provideRouter([]) ] });
RouterModule with provideRouter.HttpClientModule.Import HttpClientModule for HTTP, and provideRouter and importProvidersFrom for routing providers.