Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ion-button Click not firing up function in ionic 4

I have a button and a function in my ionic 4 Code. Ideally on the click of the button, the function should fire up but that's not happening.

MY HTML

<ion-content padding>
<div class="contentFlow" id="profile-content">
    <h1>Profile</h1>
    <ion-button (click)="clicked()"  expand="block" color="light">
      Logout
    </ion-button>
  </div>
</ion-content>

MY TS:

clicked() {
    alert('hello');
  }

Note: I need to keep the div in my code.

What should I do?

like image 805
Kumar Priyansh Avatar asked Jan 28 '19 14:01

Kumar Priyansh


People also ask

How do you use the back button on an ion?

The back button navigates back in the app's history upon click. It is smart enough to know what to render based on the mode and when to show based on the navigation stack. To change what is displayed in the back button, use the text and icon properties.

How do you post an API call in Ionic 4?

First, create a Service folder inside the app folder and generate a service using command line. Go inside to the service folder and use this command to create a service called UserService. Now inside the UserService, you can call your LastFm APIs and get the response.

How do I change the button background color in Ionic 4?

A color can be applied to an Ionic component in order to change the default colors using the color attribute. Notice in the buttons below that the text and background changes based on the color set. When there is no color set on the button it uses the primary color by default.

How do I change the button color on Ionic click?

You can use [ngClass] for the same. Based on a global property (which is to be changed after click event) you can add the desired class to the button element.


1 Answers

I have seen such things when the rendering of elements is overlapping.

You should check. There maybe an invisible layer on top of the whole element. So you can see it but you cannot interact with it. Making us feel that the simple button press is not working.

Cheers

like image 142
Leo Getz Avatar answered Nov 14 '22 23:11

Leo Getz