ion-button Click not firing up function in ionic 4

你说的曾经没有我的故事 提交于 2020-07-09 06:02:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!