Reputation: 20129
If I compile some HTML with Angular, how can I replace the contents of an DOM element with the compiled HTML? Example:
var html = "<div>{{msg}}</div>";
var scope = $scope.$new();
var scope.msg = "Hello World!";
var linkFn = $compile(html);
var contents = linkFn(scope);
element.replaceContents(contents);//what is the actual syntax for this?
Upvotes: 0
Views: 64
Reputation: 644
You want to remove the content from the element and append the newly compiled contents.
element.empty().append(contents)
Upvotes: 1