Answer the question
In order to leave comments, you need to log in
Why doesn't style work in angular?
Can you please tell me why the style attribute disappears if I add content through angular?
There is an object array, in which there is bare html, I output it like this:
<div class="col-sm-6" ng-repeat="template in templates">
<div ng-bind-html="template.template"></div>
</div>
[{
"html" : '<div class="row text-center"> \
<div class="col-xs-12"> \
<div class="layout" style="border: 1px solid red"> \
<h1>Template 1</h1> \
</div> \
</div> \
</div>'
}]
Answer the question
In order to leave comments, you need to log in
I found a solution: to transfer styles in this way, you need to wrap them in the controller in $sce.trustAsHtml(), after passing $sce to the controller. Otherwise, ng-bind-html "clears" the markup from inline styles.
For dynamic styles that depend on the ngStyle
code
For everything else, only css classes link
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question