Complete the code to enable hydration in an Angular standalone component.
import { Component, signal } from '@angular/core'; @Component({ selector: 'app-counter', standalone: true, template: `<button (click)="increment()">Count: {{ count() }}</button>`, hydrate: [1] }) export class CounterComponent { count = signal(0); increment() { this.count.update(c => c + 1); } }
Setting hydrate: true enables hydration for the component, allowing Angular to reuse server-rendered HTML on the client.
Complete the code to import the correct Angular hydration function.
import { [1] } from '@angular/platform-browser'; export function main() { bootstrapApplication(AppComponent, { providers: [ provideClientHydration() ] }); }
The function provideClientHydration is imported from @angular/platform-browser to enable client-side hydration.
Fix the error in the hydration setup by completing the bootstrap code.
import { bootstrapApplication } from '@angular/platform-browser'; import { AppComponent } from './app.component'; import { [1] } from '@angular/platform-browser'; bootstrapApplication(AppComponent, { providers: [ [1]() ] });
Both import and usage require provideClientHydration to enable client hydration properly.
Fill both blanks to create a hydrated Angular component with a signal and hydration enabled.
import { Component, [1] } from '@angular/core'; @Component({ selector: 'app-message', standalone: true, template: `<p>{{ message() }}</p>`, hydrate: [2] }) export class MessageComponent { message = signal('Hello from hydrated component!'); }
effect instead of signal for state.The signal function creates reactive state, and hydrate: true enables hydration for the component.
Fill all three blanks to create a hydrated Angular app bootstrap with client hydration and a standalone component.
import { bootstrapApplication } from '@angular/platform-browser'; import { AppComponent } from './app.component'; import { [1] } from '@angular/platform-browser'; bootstrapApplication(AppComponent, { providers: [ [2]() ] }); @Component({ selector: 'app-root', standalone: true, template: `<h1>{{ title }}</h1>`, hydrate: [3] }) export class AppComponent { title = 'Hydrated Angular App'; }
Import and use provideClientHydration to enable client hydration, and set hydrate: true in the component decorator.