0
$scope.message = '<p>test text</p>';
var html = '<div>{{::message}}</div>';

$scope.$apply(function () {
    $compile(html)($scope, function (cloned, scope) {
        $compile(cloned)(scope, function (clonedTwo, scopeTwo) {
            angular.element(myDiv).append(clonedTwo);
        });
    });
});

This results in a div element showing the following:

enter image description here

I realize that when I compile it it does it correctly. However when I try and compile it a second time it has no effect.

To fix this I need to compile the template and return raw html then use that html in the second compile.

Is there a method in angular which just renders plain html?

0

1 Answer 1

2

The method I was looking for was $interpolate.

$scope.message = '<p>test text</p>';
var html = '<div>{{::message}}</div>';

var inter = $interpolate(html)($scope);

$scope.$apply(function () {
    $compile(inter)($scope, function (cloned, scope) {
        angular.element(myDiv).append(cloned);
    });
});
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.