I have a textarea like this
<textarea><img src="..." alt="hello"/> lets go visit the beach ....</textarea>
that fetches from an external resource into a text. I am thinking of doing something like but somehow lost along the line
.controller('textCtrl', function ($scope) {
$scope.setValue = function(value){
angular.element('textarea img').val
var altValues = [];
while (true) {
var altValueMatch = textareaValue.match(/\<img.*?alt=(\"|\')(.*?)\1.*?\>/),
altValue = (Array.isArray(altValueMatch) && typeof altValueMatch[2] === "string")
? altValueMatch[2]
: null;
if (altValue !== null) {
altValues.push(altValue);
} else {
break;
}
textareaValue = textareaValue.replace(/\<img.*?\>/, "").trim();
}
//altValues.forEach(function(altValue, i) { alert("ALT VALUE " + i + ": " + altValue);})
//alert("TEXTAREA VALUE: " + textareaValue);
//alert(altValues +" "+textareaValue);
var concatenated = [altValues, textareaValue].join(" ");
//concatenated.replace(/ |,/g,"");
//alert(concatenated);
$('#messageID').val(concatenated);
When I use the above code, it fails. Please what am I doing wrong? Kindly assist