Skip to content

Instantly share code, notes, and snippets.

@planetflash
Last active July 22, 2016 22:40
Show Gist options
  • Save planetflash/4d9d66e924aae95f7618c03f2aabd4a3 to your computer and use it in GitHub Desktop.
Save planetflash/4d9d66e924aae95f7618c03f2aabd4a3 to your computer and use it in GitHub Desktop.
For fixing the issue with Angular HTML5 routing requiring the <base href="/"></base> tag, causing svg sprite icons to no longer display due to their xlink:href property. Please note, this is not a bug with Angular or Angular UI Router, but how the <base> tag is meant to behave.
<svg><use xlink:href="{{absurl+'#svgvID'}}"></use></svg>
var app = angular.module('svg-base-fix', []);
// Keep absurl up to date (for svg's)
app.run(['$rootScope', '$window', function($rootScope, $window){
$rootScope.$on('$locationChangeSuccess', function(event){
$rootScope.absurl = $window.location.href;
});
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment