How to change the behaviour of the anchor element in ionic 2?


#1

I am developing an ionic app, where I got HTML content from server side, where I have bind this html response to my page view by innerHtml API response, Now I need to change the title anchor URL so that it will open in the app instead of open in the in-app browser. I wrote one directive which reads the entire element by elementRef. But now how to change the click behaviour so that I can put my own code there to open my page.

import { Directive, ElementRef, Renderer } from '@angular/core';
import { Input, Output, EventEmitter } from '@angular/core';

@Directive({
    selector: '[stream-link]' // Attribute selector
})

export class StreamLink {
    constructor(public element: ElementRef, public renderer: Renderer) {
        console.log('Hello StreamLink Directive');
        console.log(this.element.nativeElement);
    }
}


#2

Angular really doesn’t like this sort of design, so if at all possible I would try to redo it so that you can use ordinary <a [href]="foo"> binding in a static client-side template.