This article is a mirror article of machine translation, please click here to jump to the original article.

View: 1725|Reply: 0

[Angular] Angular 18 series (twenty-five) dynamically inserts rendered HTML code

[Copy link]
Posted on 10/17/2024 9:19:28 AM | | | |
Requirements: The backend stores the svg source code, and when the frontend loads data, the interface needs to display the svg icon normally instead of the HTML code.

As shown in the following image, you need to insert a piece of HTML code at the following location and render it:



Code:


Insert the string directly into the div, and the HTML will be translated directly into the string.

You need to use innerHTML and DomSanitizer to dynamically render the HTML source code, the code is as follows:







Previous:Angular 18 series (twenty-four) custom string truncation pipes
Next:What is a UUID? and the difference between versions
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com