1

button when clicked inject a html markup that represent new product name and quantity to be added to the cart. After the client submit the form i want those product stored in an array of object.

The problem i faced is angular 6 security that hide some html tag like input.

Trying to bypass this security issue i create a Pipe called SafePipe that transform html to DomSenitizer

<div [innerHTML]="htmltobeadded | safe>

this worked fine in the template like this.

Inside the button method i used javascript to inject the htmltobeadd and the security issue came again.

document.getElementById("add").innerHTML = htmltobeadded

I use safePipe.transform() to transfrom my html to Domsenitizer

safehtml = safepipe.tranform(htmltobeadded)

and used

document.getElementById("add").innerHTML = safehtml

Error: safehtml is not assignable to type string

1 Answer 1

1

Error: safehtml is not assignable to type string

You can just cast is to any:

document.getElementById("add").innerHTML = safehtml as any
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.