0

Im doing payment gateway, after user click proceed, I send required data and getting from the back-end an base64 encode string contain html to redirect to payment gateway page.

this is what I had tried:

base64 : PCFET0NUWVBFIGh0bWw+PGh0bWw+PGJvZHk+PGgxPk15IEZpcnN0IEhlYWRpbmc8L2gxPjxwPk15IGZpcnN0IHBhcmFncmFwaC48L3A+PC9ib2R5PjwvaHRtbD4=

after I decode in my ts file using :

const decodeHtml = window.atob(this.base64);

I got result like this :

<!DOCTYPE html><html><body><h1>My First Heading</h1><p>My first paragraph.</p></body></html>

How I can display this html on my project, binding to html file or pointing out to new url ? based on my finding, i can use innerHtml to bind this, but I am not sure if there are better practice to doing this and got non idea how to display this encode html file, any suggestion are welcomed.

hafizi hamid
  • 405
  • 2
  • 20
  • 41
  • 2
    The best practice is not to do it at all. Angular isn't made to do such things. And using `innerHTML` would still be a bad practice because you would have two doctypes. –  Oct 01 '19 at 06:39
  • This might help you: https://stackoverflow.com/questions/48913344/angular-5-adding-html-content-dynamically – Prawin soni Oct 01 '19 at 07:05

0 Answers0