ocombe / ocLazyLoad

Lazy load modules & components in AngularJS
https://oclazyload.readme.io
MIT License
2.63k stars 510 forks source link

Issue loading dynamically generated (on server side) css file #403

Open gitkeerthi opened 7 years ago

gitkeerthi commented 7 years ago

Here is what I have.


$ocLazyLoad.load({
    name: 'TestModule',
    insertBefore: '#load_css_before',
    files: ['/myservice/test/css']
});

/myservice/test/css is actually a RESTful URL endpoint on the server-side generating a CSS file dynamically. When I enter this URL directly in the browser's address bar, the content loads in the browser window. However ocLazyLoad fails to load with an error "Error: no file to load has been found, if you're trying to load an existing module you should use the 'inject' method instead of 'load'."

If I modify the server side code such that the published RESTful URL endpoint now becomes '/myservice/test.css', then ocLazyLoad is able to load.

jeevasusej commented 7 years ago

You need to load like the following. For example, for the js we need to use like,

$ocLazyLoad.load({
                  insertBefore: '#loadJsBefore',
                  name: 'fancyTreeJs',
                  files: [{ type: 'js', path: 'bundles/fancytree' }]
              });