-1

I retrieve the code of an HTML page from a server thanks to a rest service and I want integrate the html code into an empty template

 .controller('TestController', ['$scope'  ,'$rootScope' , '$sce'  , function ($scope ,$rootScope,$sce) {
        var restHtml =$rootScope.test; //contains <div>Test</div>
        $scope.showHtml= $sce.trustAsHtml(restHtml );
    }]);

The template

<div ng-bind-html="showHtml"></div> <!-- didn't work and i want a solution without integrate my html code into a existing div -->

Thank you

ulquiorra
  • 931
  • 4
  • 19
  • 39
  • possible duplicate of [AngularJS How to dynamically add HTML and bind to controller](http://stackoverflow.com/questions/19845950/angularjs-how-to-dynamically-add-html-and-bind-to-controller) – Kirill Slatin Aug 02 '15 at 19:42

1 Answers1

1

Ideally DOM manipulations should not happen in the controller, directives should be used for them.

To answer your question, you could compile the html into your tag. Get the html, find the element you want to insert the html in and use compile to do it. A good example of compile.

ArslanW
  • 353
  • 1
  • 10