2

I am working on an mobile application using Ionic2 and Angular2. I have an API that return json array of strings like below:

{ 
"Go to page <a (click)='redirectToAPage(1)'> something </a>",
"Go to page <a (click)='redirectToAPage(2)'> something else  </a>",
"Go to page <a (click)='redirectToAPage(3)'> something else </a>"
}

When I run *ngFor over this array and I use

<p [innerHTML]="item"></p>

It prints the data well, but it removes (click) event. After passing it through a DomSanitizer Pipe with bypassSecurityTrustHtml function it ignores the event too.

Can anyone help please?

6
  • Angular doesn't parse and doesn't apply binding on your html. Commented Apr 24, 2017 at 11:42
  • I know that Angular does not do it by default. I need to do it and I think there must be a way. Commented Apr 24, 2017 at 11:46
  • You can create it dynamically or you can use event delegation to catch event Commented Apr 24, 2017 at 11:47
  • 1
    See stackoverflow.com/questions/43469350/… Commented Apr 24, 2017 at 11:54
  • Please find the below solution stackoverflow.com/questions/37901436/… Commented Jun 8, 2017 at 4:47

0

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.