I have a wysiwyg editor that uses a $scope.variable as it source of HTML.
Now i need to insert divs into certain parts of the HTML string. So i can programmatically append, prepend, remove etc. parts of the shown content in the wysiwyg. But i can't get the manipulation to work.
Should be simple to insert things into the dom right? But nothing gets appended in this example:
JAVASCRIPT:
var app = angular.module("app", []);
app.controller("ctrl", function($scope) {
$scope.obj = {};
// html string
$scope.obj.htmlString = ' <div class="wrapper-div">wrapper div<div class="container">container div<div class="inner-div">inner div</div></div></div>';
// element inserted into html string ( virtual dom )
$($scope.obj.htmlString).find('.container').prepend('<b>text inserted into container div</b>');
// insert the elements to dom
angular.element('.insert-here').prepend($scope.obj.htmlString);
});
HTML:
<body ng-app="app" ng-controller="ctrl">
{{ obj.htmlString }}
<div class="insert-here">
</div>
</body>
PLUNKER: