Improve this Doc View Source $sanitize

From Get docs
< Improve this Doc ngSanitize‎ | serviceAngularjs/docs/1.8/api/ngsanitize/service/$sanitize

Improve this Doc View Source $sanitize

  1. $sanitizeProvider
  2. service in module ngSanitize


Sanitizes an html string by stripping all potentially dangerous tokens.

The input is sanitized by parsing the HTML into tokens. All safe tokens (from a trusted URI list) are then serialized back to a properly escaped HTML string. This means that no unsafe input can make it into the returned string.

The trusted URIs for URL sanitization of attribute values is configured using the functions aHrefSanitizationTrustedUrlList and imgSrcSanitizationTrustedUrlList of $compileProvider.

The input may also contain SVG markup if this is enabled via $sanitizeProvider.




Param Type Details
html string HTML input.


string Sanitized HTML.


© 2010–2020 Google, Inc.
Licensed under the Creative Commons Attribution License 3.0.$sanitize