InterviewHubPRO
Section Overview
Q163

Question 163 of 283

Part 7: Change Detection, Security (XSS/Sanitizer) & Interceptors (151 - 176)

58%
Angular & Signals (283 Qs)•Part 7: Change Detection, Security (XSS/Sanitizer) & Interceptors (151 - 176)

What is the role of template compiler for prevention of XSS attacks?

The offline template compiler prevents vulnerabilities caused by template injection, and greatly improves application performance. So it is recommended to use offline template compiler in production deployments without dynamically generating any template.

Practical Code Example

text
// Role of Template Compiler:
// Pre-compiles templates into safe JavaScript functions, stripping unsafe elements and ensuring
// user-provided strings cannot inject executable HTML tags.