Skip to content

Instantly share code, notes, and snippets.

@gerzhan
Forked from IlanFrumer/uiSrefParams.js
Created April 25, 2014 08:21
Show Gist options
  • Save gerzhan/11281901 to your computer and use it in GitHub Desktop.
Save gerzhan/11281901 to your computer and use it in GitHub Desktop.
app.directive("uiSrefParams", function($state) {
return {
link: function(scope, elm, attrs) {
var params;
params = scope.$eval(attrs.uiSrefParams);
return elm.bind("click", function(e) {
var button;
if (!angular.equals($state.params, params)) {
button = e.which || e.button;
if ((button === 0 || button === 1) && !e.ctrlKey && !e.metaKey && !e.shiftKey) {
scope.$evalAsync(function() {
return $state.go(".", params);
});
return e.preventDefault();
}
}
});
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment