Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

Is there a way to add (click) programatically?

$
0
0

@murshid1988 wrote:

Can we add (click)="somemethod()" programmatically?

I am trying to find all the a tags in a div and add the click function so that they would open in In App Browser.

@ViewChild('newsSingleContent') newsDiv: any;

 ngAfterViewInit() {
let child = this.newsDiv.nativeElement;
    let matches = child.querySelectorAll('a[href]');
    matches.forEach((obj) => {
      let link = obj.href;
      obj.removeAttribute('href');
      obj.setAttribute('click', 'launch('+link+')');
    });
}

Not sure if it is the proper way to do so, but the problem is, setAttribute doesn't take "(click)". If this is not good practice, could you guide me in a proper path?

Thanks

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>