Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .directive('errorHref', function() {
- return {
- link: function(scope, element, attrs) {
- element.bind('error', function() {
- attrs.$set('ng-href', attrs.errorHref);
- });
- }
- }
- });
- <html ng-app="timeclock">
- <head ng-controller="headController">
- <link ng-href="{{urlToAppCSS}}" error-href="content/css/app.css" rel="stylesheet">
- .directive('customStyle', function($http) {
- return {
- restrict: 'E',
- scope: {
- href: '@',
- fallback: '@'
- },
- link: function(scope) {
- $http.get(scope.href)
- .then(function(response) {
- // Take the contents of the response and place into
- // a scope variable for use in the template
- scope.css = response.data;
- })
- .catch(function(response) {
- // The request failed, so instead try loading from scope.fallback url.
- });
- },
- template: '<style>{{ scope.css }}</style>'
- }
- });
- <custom-style href="{{ urlToAppCSS }}" fallback="content/css/app.css"></custom-style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement