Reputation: 49
Am new to Angularjs,Am using a ng-click option,but when i press a tab key in the keyboard ,ng-click is not capturing.Tab key is capturing only Href,how to enable Tab key to capture ng-click.
<th><a href="#/providerSearch" class="nameCross"><img src="img/cross.png" ng-click="goBack()"></a>{{firstName}} {{lastName}}</th>
<th>{{licNum}}</th>
<th>{{city}}</th>
<th>{{stCode}}</th>
<th>In Network</th>
<th>{{specialty}}</th>
<th>{{phone}}</th>
<th>{{tin}}</th>
<th class="smallWidth noteIcon" ng-click="fetchPrvdNts()" ><div ng-show="count>0" class="countBuble">{{count}}</div></th>
<th class="smallWidth moreDetails" ng-click="showMoreDtls()" ng-class="{open:!showDetailsBlock , close:showDetailsBlock}">More</th>
pressing on Tab key its focusing on first href line,but after pressing tab key there its not capturing the ng-click functionality for{{count}}.Can anyone help me with it
Upvotes: 3
Views: 2427
Reputation: 193261
Use tabindex
attribute to control what element gain focus on Tab key press. However if your goal is to allow use to navigate to clickable element with tab and then be able to trigger action with Enter or something like this, you will need to make controller listen keyboard event also, as well as click. You can do something like this:
HTML:
<a href="#" tabindex="1">Link</a>
<span ng-keypress="test($event)" ng-click="test()" tabindex="2">Test</span>
Controller:
$scope.test = function(e) {
if ((e && e.keyCode === 13) || typeof e === 'undefined') {
alert('test');
}
};
Can it be done simpler?
Upvotes: 2