我如何将angularjs $ scope对象视为div中的html。我的HTML代码是
{{topicDesc}}我正在使用
传递topicDescvar topicdesc1 = "Please ensure you read through <a href="http://adajprod.nce.amadeus.net/ABCHelp/pages/faq_home.html" target="_blank">ABC FAQ </a> and <a href="http://adajprod.nce.amadeus.net/ABCHelp/pages/help_home.html" target="_blank">ABC Help</a> before opening a request."`
$scope.topicDesc = topicDesc1;
scope.topicdesc被视为字符串,它在网页上打印相同的确切句子。我该如何解决这个问题?请帮助我更新鲜。
答案 0 :(得分:1)
您可以使用angular方法ng-bind-html将此html绑定到视图中。 它应该是这样的:
var topicdesc1 = "Please ensure you read through <a href="http://adajprod.nce.amadeus.net/ABCHelp/pages/faq_home.html" target="_blank">ABC FAQ </a> and <a href="http://adajprod.nce.amadeus.net/ABCHelp/pages/help_home.html" target="_blank">ABC Help</a> before opening a request."`
$scope.topicDesc = topicDesc1;
和
<div ng-bind-html-unsafe="topicDesc"></div
另请参阅此内容,使用角度link
将HTML插入视图答案 1 :(得分:0)
使用ng-bind-html-unsafe不是正确的方法,因为它在更高版本中已被弃用。 With ng-bind-html-unsafe removed, how do I inject HTML?将是解决此问题的正确方法。