0

How do i treat angularjs $scope object as html in div. My html code is

{{topicDesc}}

and am passing topicDesc using

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;

The scope.topicdesc is treated as string and it prints the same exact sentence on webpage. How do i solve this issue? Please help as am a fresher.

Kiran Kumar
  • 127
  • 3
  • 14

2 Answers2

1

You can bind this html into view with angular method ng-bind-html. It should be like this:

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;

and

<div ng-bind-html-unsafe="topicDesc"></div

Also see this, Insert HTML into view using angular link

Community
  • 1
  • 1
Vivek Singh
  • 169
  • 1
  • 4
0

Using ng-bind-html-unsafe is the not the right way of doing it as it has been deprecated in higher versions. With ng-bind-html-unsafe removed, how do I inject HTML? would be the right way to solve this problem.

Community
  • 1
  • 1
Kiran Kumar
  • 127
  • 3
  • 14