问题
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?
回答1:
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
回答2:
It working for me like this
html
<div text-center>
<ion-button (click)='bcWeek()' fill='clear' size='small' >
<ion-icon name='arrow-dropleft' ></ion-icon>
</ion-button>
Some text
<ion-button (click)='fwWeek()' fill='clear' size='small' >
<ion-icon name='arrow-dropright' ></ion-icon>
</ion-button>
</div>
ts
bcWeek() {
console.log('back');
}
fwWeek() {
console.log('fw');
}
@Kumar Priyansh
if you comment
<div class="contentFlow" id="profile-content">
is working?
来源:https://stackoverflow.com/questions/54404372/ion-button-click-not-firing-up-function-in-ionic-4