I am generating dynamic HTML and prepending it this way:
$scope.prepareContent = function(content, id) {
$scope.myContent =
'<div class="foo" id="' + id + '">' +
'<a href="#" ng-click="delete(' + id + ')">Delete this content</a>' +
content +
'</div>';
}
divOne = angular.element( document.querySelector('.one') );
divOne.prepend($scope.myContent);
1 - I would like to know how can I do this using a directive.
2 - I know that I have to use $compile in order to use the link generated this way. How to do this?