简体   繁体   中英

html tags considered as plain text when using angular directives

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!

您需要为此使用ng-bind-html

 <div class="help-block" ng-show="newData " ng-bind-html="offers"></div> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM