diff --git a/js/angular/directive/input.js b/js/angular/directive/input.js index b2738c7e684..4cba246547c 100644 --- a/js/angular/directive/input.js +++ b/js/angular/directive/input.js @@ -68,3 +68,31 @@ IonicModule } }; }]); + +IonicModule +.directive('ionLabel', ['$$rAF', function($$rAF) { + return { + restrict: 'E', + scope: true, + require: '?^ionInput', + compile: function($element, $attrs) { + + return function link($scope, $element, $attrs, ionInputCtrl) { + var element = $element[0]; + + $element.addClass('input-label'); + + $element.attr('aria-label', $element.text()); + var id = element.id || '_label-' + ++labelIds; + + if(!element.id) { + $element.attr('id', id); + } + + if(ionInputCtrl && ionInputCtrl.input) { + ionInputCtrl.input.setAttribute('aria-labelledby', id); + } + } + } + }; +}]); diff --git a/test/html/content.html b/test/html/content.html index abc9e2449a6..e4d15f61d4e 100644 --- a/test/html/content.html +++ b/test/html/content.html @@ -46,7 +46,7 @@