Answer the question
In order to leave comments, you need to log in
Angular chat 1. how to convert images to text?
you need to create a chat on Angular 1, it is not possible to replace smiley codes with html code when viewing sent messages, a handler was hung on the output field when binding, the following code does not produce what is expected:
var smiles = ["D83DDE0A","D83DDE03"," D83DDE09"];
$scope.renderHTML = function(html_code) {
var html_decode = html_code;
var img = '';
if(html_decode.indexOf("$#")){
for(var f = 0; f < smiles.length; f ++){
if(html_decode.indexOf(smiles[f]) !== -1){
img = document.createElement("IMG");
img.src = 'images/smile/opacity.png';
img.classList.add('ke');
img.
img.emoji = smiles[f];
var img_text = angular.element('').html(img).text();
html_decode = html_decode.replace(new RegExp(smiles[f],'g'), img_text);
}
}
}
var decoded = angular.element('').html(html_decode).text();
return $sce.trustAsHtml(decoded);
};
it turns out something like:
text [object HTMLImageElement] text
instead of html image code, can this be somehow overcome? or more precisely through what is the conversion of html to text?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question