angular-css icon indicating copy to clipboard operation
angular-css copied to clipboard

Preload with href array fails

Open cool-Blue opened this issue 8 years ago • 0 comments

in $css.preload, stylesheet.href is not tested for array-ness so,

this works...

      css: [
        'stylesheets/style.css',
        'https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.8.5/nv.d3.css',
        'views/visualize-nvd3/visialize-nvd3.css'
      ]

but this fails...

      css: {
        href: [
          'stylesheets/style.css',
          'views/visualize-nvd3/visialize-nvd3.css'
        ],
        preload: true,
        persist: true
      },

The former works whether or not preload is set true in global options.

The problem is that

        var stylesheetLoadPromises = [];
        angular.forEach(stylesheets, function(stylesheet, key) {
          stylesheet = stylesheets[key] = parse(stylesheet);
          stylesheetLoadPromises.push(
            // Preload via ajax request
            $http.get(stylesheet.href).catch(function (response) {
                if(DEBUG) $log.error('AngularCSS: Incorrect path for ' + stylesheet.href);
            })
          );
        });
        if (angular.isFunction(callback)) {
          $q.all(stylesheetLoadPromises).then(function () {
            callback(stylesheets);
          });
        }

cool-Blue avatar May 07 '17 07:05 cool-Blue