Skip to content

Instantly share code, notes, and snippets.

@mathiasverraes
Created April 5, 2012 07:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mathiasverraes/2308833 to your computer and use it in GitHub Desktop.
Save mathiasverraes/2308833 to your computer and use it in GitHub Desktop.
angluar + keymaster + $location
<!doctype html>
<html ng-app>
<script src="http://code.angularjs.org/angular-1.0.0rc3.min.js"></script>
<script src="https://raw.github.com/madrobby/keymaster/master/keymaster.min.js"></script>
<script>
function HelloCntl($scope, $location) {
$scope.name = 'World';
$location.path('/foo');
key('x', function() {
console.log('x key pressed');
$location.path('/bar'); // problem: location doesn't change
});
}
</script>
<body>
<div ng-controller="HelloCntl">
Hello {{name}}!
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment