Skip to content

Instantly share code, notes, and snippets.

@cesarandreu
Last active August 29, 2015 13:55
Show Gist options
  • Save cesarandreu/8762652 to your computer and use it in GitHub Desktop.
Save cesarandreu/8762652 to your computer and use it in GitHub Desktop.
Lets you set anchor tags that cause a full page reload instead of letting ngRoute handle the page-change
<!-- This link will be handled by ngRoute -->
<a href="/angularpage">AngularJS Link</a>
<!-- With directive, this link will cause a full page load and may be handled by your server -->
<a href="/railspage" trd-external>Rails Link</a>
<!-- Manually, this link will cause a full page load and may be handled by your server -->
<a href="/railspage" target="_self">Rails Link</a>
angular.module('tdConsoleApp')
.directive('trdExternal', function () {
'use strict';
return {
restrict: 'A',
link: function (scope, iElement) {
iElement.attr('target', '_self');
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment