Convert String to html

I want to convert the string to html. My string contains both the contents as well as html tags. I tried using this.sanitizer.bypassSecurityTrustHtml() but this didn’t worked. My string content is:

"<p>\n <strong>Privacy Statement<\/strong>\n<\/p>\n<p>\n The entity collecting the information described in this Privacy Statement is PricewaterhouseCoopers LLP, the US member firm of the PricewaterhouseCoopers\n network of firms. By using this site and submitting any personal information, you agree to the use by PricewaterhouseCoopers LLP ("PwC," "we" or\n “us”) of such information in accordance with this Privacy Statement.  This Privacy Statement may be amended from time to time by\n publishing an updated version here.\n<\/p>\n<p>\n “PwC’s Regulatory Navigator®” or “the App” means the PwC’s Regulatory Navigator® thought leadership\n application.\n<\/p>\n<p>\n "You" in this Privacy Statement means an individual user of PwC’s Regulatory Navigator®.\n<\/p>\n<p>\n This Privacy Statement describes the ways in which PwC collects and uses data through PwC’s Regulatory Navigator®. PwC’s Regulatory\n Navigator® allows all users to:\n<\/p>\n<p>\n <strong>Data collection<\/strong>\n<\/p>\n<p>\n No personally identifiable information is gathered for Users of PwC’s Regulatory Navigator®. \n<\/p>\n<p>\n To help us better understand how PwC’s Regulatory Navigator® is used, certain additional information is collected in the aggregate. This\n may include, but is not limited to, the following:\n<\/p>\n<ul type="disc">\n <li>\n Tracking site statistics for all users\n <\/li>\n <li>\n Tracking which articles are viewed the most for all users\n <\/li>\n <li>\n Tracking which videos are viewed and if they are watched in their entirety for all users\n <\/li>\n <li>\n Tracking navigation to determine if content is easily found for all users\n <\/li>\n<\/ul>\n<p>\n In addition, we may log and monitor useage in order to administer and improve the application, to protect against unauthorized access to the application,\n and to check compliance with applicable legal and contractual obligations and PwC policies and guidance.\n<\/p>\n<p>\n PwC reserves the right to monitor, edit and remove any content available on the App, but does not have\n the obligation to do so.\n<\/p>\n<p>\n <strong>Use of data<\/strong>\n<\/p>\n<p>\n Information collected in the aggregate will be used as outlined in the “Data collection” section above.\n<\/p>\n<p align="left">\n PwC’s Regulatory Navigator® does not collect or compile personally identifiable information for dissemination or sale to outside parties\n for consumer marketing purposes, or host mailings on behalf of Third Parties. If you would like to find out more about the different categories of\n information collected, please review the ‘Data collection’ section.\n<\/p>\n<p>\n <strong>Cookies <\/strong>\n<\/p>\n<p>\n PwC’s Regulatory Navigator® does not use cookies.<strong><\/strong>\n<\/p>\n<p>\n <strong>Third party links<\/strong>\n<\/p>\n<p>\n There are several places throughout PwC’s Regulatory Navigator® that link to other content that do not operate under PwC's privacy\n practices. When you link to other content, PwC's privacy practices no longer apply. We encourage visitors to review each such content site's privacy policy\n before disclosing any personally identifiable information.\n<\/p>\n<p>\n <strong>Third Parties<\/strong>\n <strong><\/strong>\n<\/p>\n<p>\n PwC is a global network with member firms around the world. We may transfer and disclose your personal information to other PwC member firms for any of the\n purposes set out in this statement. For a list of countries where PwC member firms are located, please see\n http:\/\/www.pwc.com\/gx\/en\/office-locations\/index.jhtml.\n<\/p>\n<p>\n As a result, your personal information may be transferred outside the country where you are located. This includes countries outside the European Economic\n Area (EEA) and countries that do not have laws that provide specific protection for personal information. Where we collect your personal information within\n the EEA, transfer outside the EEA will be only to a recipient in a country which provides an adequate level of protection for personal data or under an\n agreement which covers the EU requirements for the transfer of personal data to data processors or data controllers outside the EEA.\n<\/p>\n<p>\n PwC uses resources and servers located in various countries around the world to process your personal information. Your personal information may also be\n transferred to third party service providers who process information on PwC's behalf, including providers of information technology, identity management,\n website hosting and management, data analysis, data back-up, security and storage services. The third party service providers may also use their own third\n parties (sub-processors). PwC’s third party service providers and their sub-processors are bound to maintain appropriate levels of security and\n confidentiality and to process personal information as instructed by PwC.\n<\/p>\n<p>\n PwC may disclose your personal information to law enforcement, regulatory, or other government agencies or to other third parties as required by, and in\n accordance with, applicable law or regulation. PwC may also review and use your personal information to determine whether this disclosure is required or\n permitted. PwC may also disclose log files for security-related purposes.\n<\/p>\n<p>\n <strong>Access<\/strong>\n<\/p>\n<p>\n If you would like to exercise your rights under applicable to law to obtain details of personal information PwC holds about you, or to correct that\n information, please contact PwC at [Provide contact information here]. PwC may charge for a request to access your personal information, if permitted under\n applicable law. You can also contact PwC at [Provide contact information here] if you have a complaint about PwC’s handling of your personal\n information.\n<\/p>\n<p align="left">\n <strong>Retention<\/strong>\n<\/p>\n<p>\n PwC will retain your personal information for as long as is required for any of the purposes described above or longer if required by applicable law or\n regulation.\n<\/p>\n<p>\n <strong>Children<\/strong>\n<\/p>\n<p>\n PwC understands the importance of protecting children’s privacy especially in an online environment. The PwC sites covered by this privacy statement\n are not intentionally designed for or directed at children under the age of 13 years. It is PwC’s policy never to knowingly collect or maintain\n personally identifiable information about children under the age of 13.\n<\/p>\n<p>\n <strong>Security<\/strong>\n<\/p>\n<p>\n PwC has put in place appropriate technical and organizational security measures to protect your personal information from loss, misuse or destruction,\n including unauthorised or unlawful disclosure or processing of your personal information.\n<\/p>\n<p>\n <strong>Legal<\/strong>\n<\/p>\n<p>\n The information contained in this app is for general guidance on matters of interest only. The application and impact of laws can vary widely based on the\n specific facts involved. Given the changing nature\n <br\/>\n of laws, rules and regulations, and the inherent hazards of electronic communication, there may be delays, omissions or inaccuracies in information\n contained in this site. Accordingly, the information in\n <br\/>\n this app is provided with the understanding that the authors and publishers are not herein engaged in rendering legal, accounting, tax, or other\n professional advice and services. As such, it should not be used as a substitute for consultation with professional accounting, tax, legal or other\n competent advisers. Before making any decision or taking any action, you should consult a PwC professional.\n <br\/>\n <br\/>\n While we have made every attempt to ensure that the information contained in this site has been obtained from reliable sources, PwC is not responsible for\n any errors or omissions, or for the results obtained from the use of this information. All information in this app is provided "as is", with no guarantee\n of completeness, accuracy,\n <br\/>\n timeliness or of the results obtained from the use of this information, and without warranty of any kind, express or implied, including, but not limited to\n warranties of performance, merchantability and fitness for a particular purpose. In no event will PwC, its related partnerships or corporations, or the\n partners, agents or employees thereof be liable to you or anyone else for any decision made or action taken in reliance on the information in this app or\n for any consequential, special or similar damages, even if advised of the possibility of such damages.\n <br\/>\n <br\/>\n Certain links in this site connect to other websites maintained by third parties over whom PwC has no control. PwC makes no representations as to the\n accuracy or any other aspect of information contained in other websites.\n<\/p>\n"

With the innerHtml as well as this.sanitizer.bypassSecurityTrustHtml(), I was able to convert the escape characters to html elemtents only but could’t do the styling. Refer the screenshot attached below:

image

I want to add the tags to html too as well as unconverted escape characters to normal tags/symbols.

You can try to bind it to innerHTML

<div [innerHTML]=myContent></div>

I already mentioned that it didn’t helped. The screenshot I’ve attached is the output after adding innerHTML in my div.

Decoded escape characters to html manually using replace and then used it for binding with innerHTML.

Another option (simpler) :

public getSafehtml(html: string ){
var txt = document.createElement(‘textarea’);
txt.innerHTML = html
return txt.value;
}

this.description_html = this.getSafehtml(" &lt;p&gt;\n &lt;strong&gt;Privacy ....");

And use :

<div [innerHTML]="description_html" > </div>