0
votes

I have below code in the angular component in the ionic app.
In .html=>

<ion-col *ngFor="let a of article; let i=index" size="4">
         <div (click)="openArticle()">
          <ion-thumbnail slot="start">
          <ion-img [src] ="a.src" > </ion-img>
          </ion-thumbnail>
          <ion-label class="article-title">{{a.title}}</ion-label>
         </div>
        </ion-col>

In .ts =>

openArticle(){
    console.log("test")
}

If I click on tab getting openArticle is not a function at. this function should show a console message.

3
Issue resolved.Avinash Jagtap

3 Answers

0
votes

Try adding tappable to your div

<div tappable (click)=“myFunction($event)”>

0
votes

Try with below code

<ion-col *ngFor="let a of article; let i=index" size="4" tappable (click)="openArticle()">
     <ion-thumbnail slot="start">
          <ion-img [src] ="a.src" > </ion-img>
     </ion-thumbnail>
     <ion-label class="article-title">{{a.title}}</ion-label>
</ion-col>
0
votes

Can you please make sure that the openArticle() function is inside the component that refers to the .html page?

Maybe it's inside the .ts file but not inside the component class.