1
1
2
2
// Similar to Angular's ngTouch, however it uses Ionic's tap detection
3
- // and click simulation. ngClick
3
+ // and click simulation. ngClick
4
4
5
5
( function ( angular , ionic ) { 'use strict' ;
6
6
7
-
8
7
angular . module ( 'ionic.ui.touch' , [ ] )
9
8
10
9
. config ( [ '$provide' , function ( $provide ) {
@@ -15,17 +14,16 @@ angular.module('ionic.ui.touch', [])
15
14
} ] ) ;
16
15
} ] )
17
16
18
- . directive ( 'ngClick' , [ '$parse' , function ( $parse ) {
19
-
17
+ /**
18
+ * @private
19
+ */
20
+ . factory ( '$ionicNgClick' , [ '$parse' , function ( $parse ) {
20
21
function onTap ( e ) {
21
22
// wire this up to Ionic's tap/click simulation
22
23
ionic . tapElement ( e . target , e ) ;
23
24
}
24
-
25
- // Actual linking function.
26
- return function ( scope , element , attr ) {
27
-
28
- var clickHandler = $parse ( attr . ngClick ) ;
25
+ return function ( scope , element , clickExpr ) {
26
+ var clickHandler = $parse ( clickExpr ) ;
29
27
30
28
element . on ( 'click' , function ( event ) {
31
29
scope . $apply ( function ( ) {
@@ -42,9 +40,13 @@ angular.module('ionic.ui.touch', [])
42
40
scope . $on ( '$destroy' , function ( ) {
43
41
ionic . off ( 'tap' , onTap , element [ 0 ] ) ;
44
42
} ) ;
45
-
46
43
} ;
44
+ } ] )
47
45
46
+ . directive ( 'ngClick' , [ '$ionicNgClick' , function ( $ionicNgClick ) {
47
+ return function ( scope , element , attr ) {
48
+ $ionicNgClick ( scope , element , attr . ngClick ) ;
49
+ } ;
48
50
} ] )
49
51
50
52
. directive ( 'ionStopEvent' , function ( ) {
0 commit comments