0
0
Angularframework~20 mins

Pre-rendering static pages in Angular - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Angular Pre-rendering Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What will be the rendered output of this Angular component when pre-rendered?

Consider this Angular standalone component that uses pre-rendering:

import { Component, signal } from '@angular/core';

@Component({
  selector: 'app-greeting',
  standalone: true,
  template: `
    

{{ greeting() }}

` }) export class GreetingComponent { greeting = signal('Hello, Angular!'); }

What will the static HTML output be after pre-rendering?

Angular
import { Component, signal } from '@angular/core';

@Component({
  selector: 'app-greeting',
  standalone: true,
  template: `
    <h1>{{ greeting() }}</h1>
  `
})
export class GreetingComponent {
  greeting = signal('Hello, Angular!');
}
A<h1></h1>
B<h1>Hello, Angular!</h1>
C<h1>{{ greeting() }}</h1>
D<h1>undefined</h1>
Attempts:
2 left
💡 Hint

Signals provide reactive values that Angular can evaluate during pre-rendering.

lifecycle
intermediate
1:30remaining
Which Angular lifecycle hook is NOT called during pre-rendering?

When Angular pre-renders a static page, it runs some lifecycle hooks of components. Which of the following lifecycle hooks is not executed during pre-rendering?

AngOnDestroy
BngOnInit
CngOnChanges
DngAfterViewInit
Attempts:
2 left
💡 Hint

Think about hooks that are called during component cleanup.

🔧 Debug
advanced
2:30remaining
Why does this Angular pre-rendered page show empty content?

Given this Angular component used in pre-rendering:

import { Component } from '@angular/core';

@Component({
  selector: 'app-time',
  standalone: true,
  template: `

The time is: {{ currentTime }}

` }) export class TimeComponent { currentTime = new Date().toLocaleTimeString(); }

After pre-rendering, the page shows <p>The time is: </p> with no time displayed. Why?

Angular
import { Component } from '@angular/core';

@Component({
  selector: 'app-time',
  standalone: true,
  template: `<p>The time is: {{ currentTime }}</p>`
})
export class TimeComponent {
  currentTime = new Date().toLocaleTimeString();
}
AThe template syntax is incorrect and does not bind currentTime properly.
BThe component property currentTime is initialized too late, after pre-rendering.
CThe Date object is not serializable during pre-rendering, so the value is lost.
DAngular pre-rendering runs in a Node environment without locale support, so toLocaleTimeString returns an empty string.
Attempts:
2 left
💡 Hint

Consider the environment where pre-rendering runs and how JavaScript date formatting behaves there.

📝 Syntax
advanced
2:00remaining
Which option correctly configures Angular for pre-rendering static pages?

To pre-render Angular pages using Angular Universal, which configuration snippet is correct in angular.json?

A"prerender": { "builder": "@angular-devkit/build-angular:prerender", "options": { "browserTarget": "app:build", "serverTarget": "app:server" } }
B"prerender": { "builder": "@angular-devkit/build-angular:server", "options": { "browserTarget": "app:build" } }
C"prerender": { "builder": "@angular-devkit/build-angular:prerender", "options": { "browserTarget": "app:server", "serverTarget": "app:build" } }
D"prerender": { "builder": "@angular-devkit/build-angular:build", "options": { "browserTarget": "app:build", "serverTarget": "app:server" } }
Attempts:
2 left
💡 Hint

Check the builder name and targets for pre-rendering.

🧠 Conceptual
expert
3:00remaining
What is the main benefit of pre-rendering Angular pages compared to client-side rendering?

Choose the most accurate benefit of pre-rendering Angular pages as static HTML before serving to users.

APre-rendering eliminates the need for Angular's router to work on the client side.
BPre-rendering allows Angular components to run faster in the browser by skipping change detection.
CPre-rendering improves SEO and initial load speed by serving fully rendered HTML from the server.
DPre-rendering automatically updates the page content in real-time without user interaction.
Attempts:
2 left
💡 Hint

Think about what users and search engines see first when loading a pre-rendered page.