1313* <ion-input>
1414* <input type="text" placeholder="First Name">
1515* <ion-input>
16+ *
17+ * <ion-input>
18+ * <ion-label>Username</ion-label>
19+ * <input type="text">
20+ * </ion-input>
1621* </ion-list>
1722* ```
1823*/
@@ -33,18 +38,40 @@ IonicModule
3338} ] ) ;
3439
3540/**
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+ */
3863IonicModule
39- . directive ( 'inputLabel ' , [ function ( ) {
64+ . directive ( 'ionLabel ' , [ '$timeout' , function ( $timeout ) {
4065 return {
41- restrict : 'C ' ,
66+ restrict : 'E ' ,
4267 require : '?^ionInput' ,
43- compile : function ( $element ) {
68+ compile : function ( $element , $attrs ) {
4469
4570 return function link ( $scope , $element , $attrs , ionInputCtrl ) {
4671 var element = $element [ 0 ] ;
4772
73+ $element . addClass ( 'input-label' ) ;
74+
4875 $element . attr ( 'aria-label' , $element . text ( ) ) ;
4976 var id = element . id || '_label-' + ++ labelIds ;
5077
@@ -54,24 +81,33 @@ IonicModule
5481
5582 if ( ionInputCtrl && ionInputCtrl . input ) {
5683 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+
5792 }
5893 }
5994 }
6095 } ;
6196} ] ) ;
6297
98+ /**
99+ * Input label adds accessibility to <span class="input-label">.
100+ */
63101IonicModule
64- . directive ( 'ionLabel ' , [ function ( ) {
102+ . directive ( 'inputLabel ' , [ function ( ) {
65103 return {
66- restrict : 'E ' ,
104+ restrict : 'C ' ,
67105 require : '?^ionInput' ,
68- compile : function ( $element , $attrs ) {
106+ compile : function ( $element ) {
69107
70108 return function link ( $scope , $element , $attrs , ionInputCtrl ) {
71109 var element = $element [ 0 ] ;
72110
73- $element . addClass ( 'input-label' ) ;
74-
75111 $element . attr ( 'aria-label' , $element . text ( ) ) ;
76112 var id = element . id || '_label-' + ++ labelIds ;
77113
@@ -82,6 +118,7 @@ IonicModule
82118 if ( ionInputCtrl && ionInputCtrl . input ) {
83119 ionInputCtrl . input . setAttribute ( 'aria-labelledby' , id ) ;
84120 }
121+
85122 }
86123 }
87124 } ;
0 commit comments