Add a click listener to a tag dynamically added from a JSON Object

Hey everybody, first i want to thanks you guys for the great job are doing!

Im creating a news application using Ionic and retrieving data from Wordpress.

So when i get a single post content. Sometimes this post can contain images, links, iframes.

The first think im trying to do is to open a full size image on a modal when i click on it. Im getting the data from a JSON Rest Api. Unfortunately it wont be possible to add an ng-click.
So is it possible to use an event listener like : $(“myclass”).on( “click”,… using Ionic/AngularJs and whithout using Jquery ?

Thanks

Hey,

I havn’t had a need to do something like that yet but have you looked into things like ng-show/ng-hide? You can use those to show and hide components when a value it truthy or falsey

ANother thought is you could always put an if statement at the top of your method to choose wether to execute?

Maybe if you give an example i could help a bit more.

Hello @dalefrancis88.

I think i didnt explain my problem very well.

My Single post view :

<ion-view>
  <ion-content>
    <div class="card single-view">
      <div class="title" ng-bind-html="data['post'].title"></div>
      <div class="content" ng-bind-html="data['post'].content"></div>
    </div>
  </ion-content>
</ion-view>

My Post content inside <div class="content" ng-bind-html="data['post'].content"></div> contains html content that i get from my server.

What i want to do is to add a listener to the img tag (if the content of my post contains images)so i can open the full size image on a modal when a user click on it