What happens if you use tag inside template?
What happens if you use tag inside template?
When you use a <script> tag inside an Angular template, Angular treats this tag as unsafe and automatically sanitizes it. This means that Angular removes the <script> tag from the template to prevent potential security risks, such as script injection attacks. However, it retains any safe content, such as the text content of the script tag, ensuring that the rest of the template remains unaffected.
Angular's sanitization process is part of its security features designed to protect applications from cross-site scripting (XSS) vulnerabilities. For instance, if you attempt to bind a script tag through the innerHtml property, Angular will sanitize the input to prevent the script from executing.
Đăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.