How can I handle the space bar key event in Angular? Here are some possible solutions:
ng-keyup="$event.keyCode == 32 ? '/settings' : null"
ng-keyup="$event.keyCode == 32 ? '#/settings' : null"
ng-keyup="$event.keyCode == 32 ? $eval('/settings') : null"
ng-keyup="$event.keyCode == 32 ? $eval('#/settings') : null"
ng-keyup="$event.keyCode == 32 ? $eval(/settings) : null"
ng-keyup="$event.keyCode == 32 ? go('/settings') : null"
ng-keyup="$event.keyCode == 32 ? go('#/settings') : null"
ng-keyup="$event.keyCode == 32 ? go(#/settings) : null"
ng-keyup="$event.keyCode == 32 ? $location.path('/settings') : null"
ng-keyup="$event.keyCode == 32 ? $location.path('#/settings') : null"
ng-keyup="$event.keyCode == 32 ? javascript:angular.element(document.getElementById('MainController')).scope().go('#/settings') : null"
ng-keyup="$event.keyCode == 32 ? javascript:angular.element(document.getElementById('MainController')).scope().go('#/settings') : null"
In my project using AngularJS, Bootstrap, and FontAwesome, ui-router is responsible for handling main menu links. An example of such a link:
<li role="presentation">
<a id="settings-tab" ui-sref="settings" tabindex="2" role="tab"
ng-keyup="$event.keyCode == 32 ? go('/settings') : null"
<span class="fa fa-cog fa-fw"></span>Settings</a>
</li>
When using ui-router, the ui-sref="settings" attribute translates to href="/settings"