각도 설정 방법JS 출력 이스케이프 HTML
서버에서 JSON 데이터를 가져오고 있는데 필드 중 하나에 이스케이프 html(실제로 이메일 본문)이 포함되어 있습니다.
<html>\r\n<head>\r\n<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">\r\n</head>\r\n<body dir="auto">\r\n<div>Buonasera, ho verificato i dati sul mio account ed il numero di cell che vi ho fornito</div>\r\n<div><br>\r\n<a
(더...)
AngularJs로 렌더링하려고 하니까 미치겠어요.
다음 기능이 작동하지 않습니다.
<div ng-bind-html-unsafe="mail.htmlbody"></div>
HTML이 실제로 탈출했기 때문에 정상이라고 생각합니다.일단 탈출부터 해야 되나?Angular는 사용 가능한 서비스로 html을 이스케이프 해제할 수 있습니까?
$sce를 다음과 같이 사용하는 경우:
scope.mail.htmlbody = $sce.trustAsHtml(scope.mail.htmlbody);
소스의 html이 표시되고, 내용을 확인할 수 있는 요소를 조사합니다.즉, 페이지에 html이 렌더링되는 대신 원본 html이 표시됩니다.내가 뭘 놓쳤나?
동시에$sce
서비스가 도입되었습니다(예: 1.2).ng-bind-html-unsafe
디렉티브가 폐기되었습니다.새로운 디렉티브는ng-bind-html
이것을 사용하는 경우, 코드는 문서화된 대로 동작합니다.
<div ng-bind-html="mail.htmlbody"></div>
다음 지시문을 사용합니다.
<div ng-bind-html="mail.htmlbody"></div>
앱 모듈에서 각도 소독을 사용하는 것을 잊지 마십시오.
http://docs.angularjs.org/api/ngSanitize 를 참조해 주세요.
언급URL : https://stackoverflow.com/questions/20436579/how-to-have-angularjs-output-escaped-html
'sourcecode' 카테고리의 다른 글
각도 2 베타17: 속성 '맵'이 '관측 가능' 유형에 없습니다. (0) | 2023.02.11 |
---|---|
문서 본문 스크롤을 비활성화하려면 어떻게 해야 합니까? (0) | 2023.02.11 |
angularJS는 Base64 이미지를 표시합니다. (0) | 2023.02.11 |
AJAX(특히 jQuery)를 통해 로드된 Javascript를 디버깅하려면 어떻게 해야 합니까? (0) | 2023.02.11 |
woocommerce에 모든 주문을 볼 수 있는 쇼트 코드/페이지가 있습니까? (0) | 2023.02.11 |