user2920788 user2920788 - 2 months ago 12
HTML Question

Replace text with angular

I am trying to replace certain values in a div using angular. The problem is that the div content is generated by an outside service so I cant just add

ng-model
and be done with it. I've tried the following and some various variations with no luck

var o = angular.element(document.querySelector('#maintwo'));
var r = o[0].innerHTML.replace('TWO','REPLACE');
angular.element(document.querySelector('#maintwo')).innerHTML = r;


plunker

Answer

just remove angular.element() from this line, and it will work as you need it : angular.element(document.querySelector('#maintwo')).innerHTML = r;

Do it , like : document.querySelector('#maintwo').innerHTML = r;