javascript 离子 4 角度 6 中的离子输入 onclick
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/52167017/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ion-input onclick in ionic 4 angular 6
提问by lsantamaria
I have a view with a ion-input inside a form:
我在表单中有一个带有离子输入的视图:
<form class="inputs-in-block" [formGroup]="userForm">
<ion-input type="text" placeholder="Username" (click)='onClickFuntion($event)'></ion-input>
</form>
I want to catch the onClick event after it is fired, but I do not manage to achieve it because after clicking on the input, the onClickFunction($event)is not called.
This is the definition of the function:
我想在它被触发后捕获 onClick 事件,但我没有设法实现它,因为在点击输入后,onClickFunction($event)没有被调用。这是函数的定义:
onClickFunction(event) {
console.log('Event caught');
}
I have tried without the event and it is not working either.
我在没有事件的情况下尝试过,但它也不起作用。
Is the click event available for s in the latest version? Any idea to solve it?
最新版本的s有点击事件吗?任何想法来解决它?
回答by fransyozef
I think it's a typo:
我认为这是一个错字:
You have in your template:
您的模板中有:
(click)='onClickFuntion($event)'
But in your ts file :
但是在您的 ts 文件中:
onClickFunction(event) {
console.log('Event caught');
}
onClickFuntion <-> onClickFunction ... see the "c"
onClickFuntion <-> onClickFunction ... 见“c”
回答by SiddAjmera
You'll have to send it as well from the template. That's missing from your template. (click)='onClickFuntion($event)
您还必须从template. 您的模板中缺少这一点。(click)='onClickFuntion($event)
<ion-input
type="text"
placeholder="Username"
(click)='onClickFuntion($event)'>
</ion-input>
回答by FrontEndOnDemand
I think, you should use ionClickto trigger click event.
我认为,您应该使用ionClick来触发点击事件。
You'r code should work if you do below changes
如果您进行以下更改,您的代码应该可以工作
<form class="inputs-in-block" [formGroup]="userForm">
<ion-input type="text" placeholder="Username" (ionClick)='onClickFuntion($event)'></ion-input>
</form>

