Click event not working, "co.console.log () is not a function"

I'm trying to get a button to work to open a page by passing an object in the parameters, but for some reason it gives me an error

"co. is not a function."

I don't know what the problem is, because it is giving me the same error when I try to use alert

or console.log

or whatever.

HTML page :

<ion-header>

   <ion-navbar>
       <ion-title>SearchResults</ion-title>
   </ion-navbar>

</ion-header>


<ion-content padding>
    <ion-list>
        <ion-item *ngFor= "let item of resultArray;">
            <img src={{item.thumbnail}} />
            <p>{{item.title}}</p>
            <button bookDetail (click)="console.log(\"Even some text, please?\")">DETAIL</button>
        </ion-item>
    </ion-list>
</ion-content>

      

+3


source to share


1 answer


In your file, ts

just follow these steps.

.ts

log():void {
 console.log('Your message here');
}

      



Html

<button ion-button (click)="log()">DETAIL</button>

      

Note. ... If you need to pass item

, just do this: log(item)

side html

and ts

side log(data):void {}

.

+8


source







All Articles