I had the same challenge. Make sure that your angular app is initialized on the html tag. Then this solution works out of the box.
However for us this was not an ideal solution. So I modified Zack Boman (tennisgent) https://github.com/tennisgent/angular-route-styles code, so that it could be used anywhere after app initialization.
- Renamed the directive to: zbRouteStyles
- Modified the restrict to include attributes: restrict: 'EA'
- Changed the line:
elem.append($compile(html)(scope));
to
angular.element('head').append($compile(html)(scope));
With these changes I was able to add the directive to any tag after my angular app was initialized even the tag that my app is initialized on.
e.g.:
<div ng-app="myApp" zb-Route-Styles>
<div>