0

I'm trying to render html content from a controller , but the angular directive ng-hide doesn't work , I've tried the following code, does it have a problem with binding as html this way?

      var htmlContent = "<Div class='vzone'  ng-hide='true' id='parent_" +  ViewerZones[CurrentIndex].Id + "'...'></div>";
  
$scope.PageContent = $sce.trustAsHtml(htmlContent);
<div  ng-bind-html="PageContent"></div>
user3248711
  • 47
  • 1
  • 1
  • 10

1 Answers1

0

try this one,

 var htmlContent = "<Div class='vzone'  ng-.....

$scope.PageContent = $sce.trustAsHtml($compile(htmlContent));

don't forget to add $compile dependency in your controller.

$compile service will bind your dynamic directives with the controller

Kalhan.Toress
  • 21,683
  • 8
  • 68
  • 92
  • I tried it but gives the following exception "Attempted to trust a non-string value in a content requiring a string: Context: htmlContent" – user3248711 Nov 18 '14 at 08:56