Last active
December 22, 2015 09:49
-
-
Save thewarpaint/6454594 to your computer and use it in GitHub Desktop.
Angular directive to generate a normal link and another one to be opened in a new window/tab from a URL.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('LinkWidget') | |
.directive('linkWidget', function() { | |
var directive = { | |
template: '<span><a ng-href="{{ url }}" target="_blank" class="external-link add-tooltip" title="{{ blankTitle }}"><i class="icon-external-link"></i></a> ' + | |
'<a ng-href="{{ url }}">{{ text }}</a></span>', | |
replace: true, | |
restrict: 'EA', | |
scope: { | |
url: '@url', | |
text: '@text', | |
blankTitle: '@blankTitle' | |
}, | |
controller: ['$scope', function($scope) { | |
$scope.blankTitle = $scope.blankTitle || 'Open in a new window or tab'; | |
}] | |
}; | |
return directive; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Depends on FontAwesome to display the external-link icon. --> | |
<link-widget url="http://manoderecha.mx" text="A project management web app."></link-widget> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment