Ashwin Ramaswami
Ashwin Ramaswami

Reputation: 913

Ionic 2 images popup (angular 2 dynamic binding)

In my Ionic 2 app, I have some HTML that I am pulling from a server. I want that if the user clicks on an <img />, then it should show the image in a fullscreen popup.

How do I do this -- basically, adding a ng-click to all img tags in dynamically generated content? The only way I can think of is using jQuery...

Upvotes: 2

Views: 630

Answers (1)

Jamil
Jamil

Reputation: 939

No need to use jQuery, you can bind the event on the container of the retrieved HTML for example:

<div (click)="clickHandler($event.target)">
 <!-- retrieved HTML here -->
</div>

clickHandler(e: HTMLElement){
    console.log(e); // here is the element which has been clicked  
}

and if you want to open the image in the fullscreen popup you can use FileOpener plugin , and it will be opened in the native viewer

Upvotes: 2

Related Questions