I am building a navigation tree in Angular JS. Most links in the tree will point to pages within my website, but some may point to external sites.
If the href of a l
A more simple directive does not require changes in your HTML by handling all tags, and adding target="_blank" if someURL does not target the current host:
yourModule.directive('a', function() {
return {
restrict: 'E',
link: function(scope, elem, attrs) {
var a = elem[0];
if (a.hostname != location.host)
a.target = '_blank';
}
}
}