linkifyjs icon indicating copy to clipboard operation
linkifyjs copied to clipboard

linkifyHtml events with ionic v1 / angular

Open tobischulz opened this issue 8 years ago • 1 comments

Hello,

is there a way to add a click event on angular (ionic v1) ? Everything works perfect but an event in options for linkifyHtml needs jquery. Is there a way to add a onlick event on parsed url?

Thank you

tobischulz avatar May 08 '17 09:05 tobischulz

I did some tricks for this purpose. Try adding the attribute "onclick" in the options. For example, in my case I wanted to open the link in the system browser. If I only set the target, the link still opens in the same webview of my app.

linkifyString(text, {
    attributes: {
        onclick: "window.open(this.href, '_system', 'location=yes'); event.preventDefault();"
    },
    target: '_system',
})

After that, it's possible that you will see the error WARNING: sanitizing HTML stripped some content. Then, this answer may help you.

*PS: I'm using Ionic v3/Angular 4, but I think this can be resolve in the same way.

pcsantana avatar Jun 01 '17 21:06 pcsantana