Reputation: 913
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
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