Ejemplo: caracteres especiales html decodificar angular
// this function remove all html tags in text
extratHtmlTags(content) {
return content.replace(/<[^>]*>/g, '');
}
// this function decode html special characters in text
decodeSpecialEntitiesHtml(htmlentities) {
const str = document.createElement("textarea");
str.innerHTML = htmlentities;
return str.value;
}
// this function conver all html tags and special characters to simple text
htmlEntitiesdecode(html){
return this.extratHtmlTags(this.decodeSpecialEntitiesHtml(html) );
}
// Exemple
const html = '<label for="target">My name is Pierre Yem Mback: Autres questions posées sur le système ? :</label>';
console.log(this.extratHtmlTags(this.html));
console.log(this.decodeSpecialEntitiesHtml(this.html));
console.log(this.htmlEntitiesdecode(this.html));
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)