Advertisement
Guest User

Untitled

a guest
Aug 29th, 2015
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. .directive('errorHref', function() {
  2. return {
  3. link: function(scope, element, attrs) {
  4. element.bind('error', function() {
  5. attrs.$set('ng-href', attrs.errorHref);
  6. });
  7. }
  8. }
  9. });
  10.  
  11. <html ng-app="timeclock">
  12. <head ng-controller="headController">
  13. <link ng-href="{{urlToAppCSS}}" error-href="content/css/app.css" rel="stylesheet">
  14.  
  15. .directive('customStyle', function($http) {
  16. return {
  17. restrict: 'E',
  18. scope: {
  19. href: '@',
  20. fallback: '@'
  21. },
  22. link: function(scope) {
  23. $http.get(scope.href)
  24. .then(function(response) {
  25. // Take the contents of the response and place into
  26. // a scope variable for use in the template
  27. scope.css = response.data;
  28. })
  29. .catch(function(response) {
  30. // The request failed, so instead try loading from scope.fallback url.
  31. });
  32. },
  33. template: '<style>{{ scope.css }}</style>'
  34. }
  35. });
  36.  
  37. <custom-style href="{{ urlToAppCSS }}" fallback="content/css/app.css"></custom-style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement