ngSanitize.$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 whitelist) are then serialized back to properly escaped html string. This means that no unsafe input can make it into the returned string.

The whitelist for URL sanitization of attribute values is configured using the functions aHrefSanitizationWhitelist and imgSrcSanitizationWhitelist of $compileProvider.

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

Usage

$sanitize(html);

Arguments

Param Type Details
html string

HTML input.

Returns

string

Sanitized HTML.

© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://code.angularjs.org/1.5.11/docs/api/ngSanitize/service/$sanitize

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部