Challenge - 5 Problems
Angular Bootstrap Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2: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);
Attempts:
2 left
💡 Hint
Think about what Angular needs to do first to show anything on the screen.
✗ Incorrect
When Angular bootstraps a standalone component, it creates the component instance and inserts it into the DOM at the root element. It does not compile modules because standalone components don't require NgModules. Lifecycle hooks run after creation, and Angular does not wait for user interaction to render.
❓ lifecycle
intermediate2: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'); } }
Attempts:
2 left
💡 Hint
The root component has no @Input properties, so ngOnChanges is skipped.
✗ Incorrect
During Angular bootstrap of the root component, ngOnChanges is called first if there are any input property changes. However, for the root component with no @Input properties, ngOnChanges is not called. Therefore, ngOnInit is the first lifecycle hook called.
📝 Syntax
advanced2:00remaining
Identify the correct syntax to bootstrap an Angular standalone component
Which code snippet correctly bootstraps a standalone Angular component named
AppComponent?Attempts:
2 left
💡 Hint
Remember the new Angular 17+ way to bootstrap standalone components.
✗ Incorrect
The correct way to bootstrap a standalone component is using
bootstrapApplication(). The other options are either for NgModules or invalid functions.🔧 Debug
advanced2: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();
Attempts:
2 left
💡 Hint
Check the function call and its parameters.
✗ Incorrect
The function bootstrapApplication requires the root component to be passed as an argument. Calling it without arguments causes an error.
🧠 Conceptual
expert2:00remaining
What is the role of
platformBrowser in Angular bootstrapping?During Angular's bootstrap process, what does
platformBrowser() provide?Attempts:
2 left
💡 Hint
Think about what 'platform' means in Angular's context.
✗ Incorrect
platformBrowser() creates the platform that allows Angular to run in the browser. It sets up the environment for the app to execute in a web browser.