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:
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?
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:
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?
Share Improve this question edited Sep 4, 2018 at 13:14 lsantamaria asked Sep 4, 2018 at 13:04 lsantamarialsantamaria 1781 gold badge2 silver badges12 bronze badges 2- Are you testing the click on a device or in your browser? – fransyozef Commented Sep 4, 2018 at 14:07
- Yes, in my browser – lsantamaria Commented Sep 4, 2018 at 14:08
3 Answers
Reset to default 2I think it's a typo:
You have in your template:
(click)='onClickFuntion($event)'
But in your ts file :
onClickFunction(event) {
console.log('Event caught');
}
onClickFuntion <-> onClickFunction ... see the "c"
You'll have to send it as well from the template
. That's missing from your template. (click)='onClickFuntion($event)
<ion-input
type="text"
placeholder="Username"
(click)='onClickFuntion($event)'>
</ion-input>
I think, you should use ionClick
to trigger click event.
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>