Last active
July 22, 2016 22:40
-
-
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.
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
<svg><use xlink:href="{{absurl+'#svgvID'}}"></use></svg> |
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
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