Intermedio
4 ottobre 2026

Trova il bug: Angular

Uno snippet di codice. Trova il bug, o dimostra che non ce n'è.

typescript
1import { Component } from '@angular/core';
2import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
3
4@Component({
5  selector: 'app-comment',
6  template: '<div [innerHTML]="safeComment"></div>'
7})
8export class CommentComponent {
9  safeComment: SafeHtml = '';
10  userComment = '';
11
12  constructor(private sanitizer: DomSanitizer) {}
13
14  displayComment(input: string) {
15    this.userComment = input;
16    this.safeComment = this.sanitizer.bypassSecurityTrustHtml(input);
17  }
18}

Clicca sulle righe che causano il problema.

Il tuo verdetto

Un tentativo al giorno. La risposta appare subito dopo.

Mantieni la tua serie

Crea un account per conservare la tua serie e seguire i tuoi progressi.

Crea un account