13
13
* <ion-input>
14
14
* <input type="text" placeholder="First Name">
15
15
* <ion-input>
16
+ *
17
+ * <ion-input>
18
+ * <ion-label>Username</ion-label>
19
+ * <input type="text">
20
+ * </ion-input>
16
21
* </ion-list>
17
22
* ```
18
23
*/
@@ -33,18 +38,40 @@ IonicModule
33
38
} ] ) ;
34
39
35
40
/**
36
- * Input label adds accessibility to <span class="input-label">.
37
- */
41
+ * @ngdoc directive
42
+ * @name ionLabel
43
+ * @parent ionic.directive:ionList
44
+ * @module ionic
45
+ * @restrict E
46
+ *
47
+ * New in Ionic 1.2. It is strongly recommended that you use `<ion-label>` in place
48
+ * of any `<label>` elements for maximum cross-browser support and performance.
49
+ *
50
+ * Creates a label for a form input.
51
+ *
52
+ * @usage
53
+ *
54
+ * ```html
55
+ * <ion-list>
56
+ * <ion-input>
57
+ * <ion-label>Username</ion-label>
58
+ * <input type="text">
59
+ * </ion-input>
60
+ * </ion-list>
61
+ * ```
62
+ */
38
63
IonicModule
39
- . directive ( 'inputLabel ' , [ function ( ) {
64
+ . directive ( 'ionLabel ' , [ '$timeout' , function ( $timeout ) {
40
65
return {
41
- restrict : 'C ' ,
66
+ restrict : 'E ' ,
42
67
require : '?^ionInput' ,
43
- compile : function ( $element ) {
68
+ compile : function ( $element , $attrs ) {
44
69
45
70
return function link ( $scope , $element , $attrs , ionInputCtrl ) {
46
71
var element = $element [ 0 ] ;
47
72
73
+ $element . addClass ( 'input-label' ) ;
74
+
48
75
$element . attr ( 'aria-label' , $element . text ( ) ) ;
49
76
var id = element . id || '_label-' + ++ labelIds ;
50
77
@@ -54,24 +81,33 @@ IonicModule
54
81
55
82
if ( ionInputCtrl && ionInputCtrl . input ) {
56
83
ionInputCtrl . input . setAttribute ( 'aria-labelledby' , id ) ;
84
+
85
+ $element . on ( 'click' , function ( e ) {
86
+ console . log ( 'CLICK' ) ;
87
+ $timeout ( function ( ) {
88
+ ionInputCtrl . input . focus ( ) ;
89
+ } )
90
+ } )
91
+
57
92
}
58
93
}
59
94
}
60
95
} ;
61
96
} ] ) ;
62
97
98
+ /**
99
+ * Input label adds accessibility to <span class="input-label">.
100
+ */
63
101
IonicModule
64
- . directive ( 'ionLabel ' , [ function ( ) {
102
+ . directive ( 'inputLabel ' , [ function ( ) {
65
103
return {
66
- restrict : 'E ' ,
104
+ restrict : 'C ' ,
67
105
require : '?^ionInput' ,
68
- compile : function ( $element , $attrs ) {
106
+ compile : function ( $element ) {
69
107
70
108
return function link ( $scope , $element , $attrs , ionInputCtrl ) {
71
109
var element = $element [ 0 ] ;
72
110
73
- $element . addClass ( 'input-label' ) ;
74
-
75
111
$element . attr ( 'aria-label' , $element . text ( ) ) ;
76
112
var id = element . id || '_label-' + ++ labelIds ;
77
113
@@ -82,6 +118,7 @@ IonicModule
82
118
if ( ionInputCtrl && ionInputCtrl . input ) {
83
119
ionInputCtrl . input . setAttribute ( 'aria-labelledby' , id ) ;
84
120
}
121
+
85
122
}
86
123
}
87
124
} ;
0 commit comments