Reputation: 39
for example:
function foo()
located in my controller:
$scope.getOffers = function(){
var txt1="aaaa"+"<br>"+"bbbb";
$scope.newData = txt1;
};
and my html:
<div class="help-block" ng-show="newData ">{{ offers }}</div>
and when I called foo()
the text that showed up was:
aaaa<br>bbbb
instead of :
aaaa
bbbb
(I already tried to insert \n
in my text...)
What am I missing? and how can I fix the problem?
thanks!
Upvotes: 0
Views: 191
Reputation: 354
And don't forget to trust the html. https://docs.angularjs.org/api/ng/service/$sce
See this plunker http://embed.plnkr.co/HAKJ2iknZeeEOsgukoGd/
Upvotes: 1
Reputation: 6393
you need use ng-bind-html for this
<div class="help-block" ng-show="newData " ng-bind-html="offers"></div>
Upvotes: 1