ngclick deprecated. Popular alternative or solution?
Asked Answered
B

1

6

I'm new to angular. ng-click seems like a pretty core directive, I don't understand how you can make an app without ng-click. Am I missing something? Apparently it's deprecated. And the docs point me to fastclick but that's not an angular implementation.

Is there a popular non-deprecated way of doing what ng-click did? I couldn't find any popular packages on bower for this. Thanks.

Basketwork answered 11/5, 2016 at 11:37 Comment(1)
nice clickbait titleBarbary
D
11

ng-click is only being deprecated within the ngTouch module due to delays when used in mobile browsers.

Beginning with Angular 1.5, this directive is deprecated and by default disabled. The directive will receive no further support and might be removed from future releases. If you need the directive, you can enable it with the $touchProvider#ngClickOverrideEnabled function. We also recommend that you migrate to FastClick. To learn more about the 300ms delay, this Telerik article gives a good overview.

Regular ngClick in the core ng module will remain unaffected.

If you do infact need to use fastclick as an alternative there are a couple of angular wrapped versions available. One, Two.

Difficulty answered 11/5, 2016 at 11:49 Comment(1)
I find fastClick hard to use. You have to add a bunch of event listeners yourself, from how I understand it, and cannot use a simple directive like with ng-click. Is ng-cklick not working on mobiles at all? Or just not recommended? I've always worked with ng-click on mobiles and it went fine. Don't understand the need to skip ng-click.Chaulmoogra

© 2022 - 2024 — McMap. All rights reserved.