Link inside an ion-item not working


#1

Hi,

I have a link inside an ion-item and I don’t know why it’s not working.

Here is my code:

<ion-item text-wrap no-lines>
<h2 [innerHTML]="myText | linker"></h2>
</ion-item>

Linker is a Pipe that detects a link in myText and generates the real html link.

Any help, please?


#2

Put it in the ion-item tag, and use this ui-sref.

Edit: didn’t notice that it’s Ionic 2!


#3

ui-sref?

I am using Ionic 2 :S


#4

@Corin Do you know if it works in Angular 2? Using [innerHTML] like that looks suspicious to me, but maybe someone more knowledgeable will come along. I wouldn’t do it that way though. I’d use

<ion-item>
<a href="{{expression}}">Text</a>
</ion-item>

#5

Yes @AaronSterling , [innerHTML] is part of Angular2 and its working for html elements, but my problem is that i need to bind links and this is not working for me :frowning:

And I can’t do using your way because is a chat app and we can have much more text and with more than one link :S


#6

But anti-XSS sanitization is part of Angular 2 also and the security docs explicitly say they sanitize [innerHTML]. That doesn’t affect your use case?


#7

Yes, you are totally right. I think so :frowning: