0
0
Angularframework~20 mins

How Angular bootstraps an application - Practice Exercises

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Angular Bootstrap Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What happens when Angular bootstraps a standalone component?
Consider an Angular standalone component bootstrapped with bootstrapApplication(). What is the first thing Angular does during this bootstrap process?
Angular
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';

bootstrapApplication(AppComponent);
AAngular creates the component instance and inserts it into the DOM at the root element.
BAngular immediately runs all lifecycle hooks of every component in the app.
CAngular compiles the entire application module before creating any component.
DAngular waits for user interaction before rendering the component.
Attempts:
2 left
💡 Hint
Think about what Angular needs to do first to show anything on the screen.
lifecycle
intermediate
2:00remaining
Which lifecycle hook runs first during Angular bootstrap?
When Angular bootstraps a component, which lifecycle hook is called first?
Angular
import { Component, OnInit, OnChanges } from '@angular/core';

@Component({
  selector: 'app-root',
  template: `<p>Hello</p>`
})
export class AppComponent implements OnInit, OnChanges {
  ngOnChanges() { console.log('OnChanges'); }
  ngOnInit() { console.log('OnInit'); }
}
AngOnChanges
BngDoCheck
CngAfterViewInit
DngOnInit
Attempts:
2 left
💡 Hint
The root component has no @Input properties, so ngOnChanges is skipped.
📝 Syntax
advanced
2:00remaining
Identify the correct syntax to bootstrap an Angular standalone component
Which code snippet correctly bootstraps a standalone Angular component named AppComponent?
AbootstrapStandalone(AppComponent);
BplatformBrowserDynamic().bootstrapModule(AppComponent);
CbootstrapModule(AppComponent);
DbootstrapApplication(AppComponent);
Attempts:
2 left
💡 Hint
Remember the new Angular 17+ way to bootstrap standalone components.
🔧 Debug
advanced
2:00remaining
Why does this Angular bootstrap code fail?
Given this code, why does Angular fail to bootstrap the application?
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';

bootstrapApplication();
Angular
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';

bootstrapApplication();
AAngular requires a module to bootstrap, not a standalone component.
BAppComponent is not imported correctly, causing a runtime error.
CbootstrapApplication requires the root component as an argument, but none was provided.
DThe import statement for bootstrapApplication is incorrect.
Attempts:
2 left
💡 Hint
Check the function call and its parameters.
🧠 Conceptual
expert
2:00remaining
What is the role of platformBrowser in Angular bootstrapping?
During Angular's bootstrap process, what does platformBrowser() provide?
AIt manages the routing and navigation of the Angular application.
BIt creates a platform that enables Angular to run in a browser environment.
CIt compiles the Angular components into browser-compatible JavaScript.
DIt initializes the Angular service worker for offline support.
Attempts:
2 left
💡 Hint
Think about what 'platform' means in Angular's context.