Steven Johnston Steven Johnston - 1 year ago 166
AngularJS Question

Angularjs set style for ng-bind-html

im trying to set the style for a div i create in my angularjs code. I can set the class but I cant set the style. I have tried just using style tag and that didn't work either. I have

$scope.myHTML='<div style="left:300px;" class="squareButton"><h1>SomeText</h1></div>';

I've tried other things in the style tag but nothing works. It will work if i put it in the css file. is there a way i can do it in the style=""? i need to make multiple divs with different positions. so i can't just use the css. how do i get the style tag to work?

Answer Source

Is there any errors in the Web Developer Console? Or did you trusted the HTML with $sce?

function MyCtrl($scope, $sce) {
  $scope.myHTML = $sce.trustAsHtml(...)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download