簡體   English   中英

使用角度指令時將html標簽視為純文本

[英]html tags considered as plain text when using angular directives

例如:

位於我的控制器中的函數foo()

              $scope.getOffers = function(){
                 var txt1="aaaa"+"<br>"+"bbbb";
                  $scope.newData = txt1;
              };

和我的HTML:

                <div class="help-block" ng-show="newData ">{{ offers }}</div> 

當我調用foo() ,顯示的文本是: aaaa<br>bbbb而不是:

        aaaa
        bbbb

(我已經嘗試在文本中插入\\n ...)我想念什么? 以及如何解決該問題?

謝謝!

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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM