Skip to content

Commit 1a91bb2

Browse files
committed
ion-label
1 parent 6383933 commit 1a91bb2

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

Diff for: js/angular/directive/input.js

+28
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,31 @@ IonicModule
6868
}
6969
};
7070
}]);
71+
72+
IonicModule
73+
.directive('ionLabel', ['$$rAF', function($$rAF) {
74+
return {
75+
restrict: 'E',
76+
scope: true,
77+
require: '?^ionInput',
78+
compile: function($element, $attrs) {
79+
80+
return function link($scope, $element, $attrs, ionInputCtrl) {
81+
var element = $element[0];
82+
83+
$element.addClass('input-label');
84+
85+
$element.attr('aria-label', $element.text());
86+
var id = element.id || '_label-' + ++labelIds;
87+
88+
if(!element.id) {
89+
$element.attr('id', id);
90+
}
91+
92+
if(ionInputCtrl && ionInputCtrl.input) {
93+
ionInputCtrl.input.setAttribute('aria-labelledby', id);
94+
}
95+
}
96+
}
97+
};
98+
}]);

Diff for: test/html/content.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ <h1 class="title">Title</h1>
4646
<textarea placeholder="Comments"></textarea>
4747
</ion-input>
4848
<ion-input class="item item-input">
49-
<span class="input-label">Username</span>
49+
<ion-label>Username</ion-label>
5050
<input type="text">
5151
</ion-input>
5252
</div>

0 commit comments

Comments
 (0)