0

I'm using ocLazyLoad and initialize it at ui-router resolve:

$stateProvider
   .state('user', {
       url: '/user',
       resolve: {
       loader: ['$ocLazyLoad', function ($ocLazyLoad) {
            return $ocLazyLoad.load('app/user/user.app.js');
           }]
       }
    })
   .state('admin', {
       url: '/admin',
       resolve: {
       loader: ['$ocLazyLoad', function ($ocLazyLoad) {
            return $ocLazyLoad.load('app/admin.app.js');
           }]
       }
    })

The problem is when I first reload the page (to /admin), it works perfectly. But if i go to /user (still load) and back again to /admin the JS won't load. and still using /userjs.

I've tried add cache:false for every route stil not working.

Any solution?

ssuhat
  • 7,387
  • 18
  • 61
  • 116
  • i use $ocLazyLoad who work perfectly but i dont use $stateProvider but $routeProvider – AlainIb Dec 07 '15 at 08:26
  • oh my project already using $stateProvider. it's take too many time to change it to $routeprovider. and i read at oclazyload docs, it says working with $stateprovider. even their example using $stateprovider – ssuhat Dec 07 '15 at 08:34
  • of course. in my app it load only one time the js file and keep them in memory – AlainIb Dec 07 '15 at 08:48
  • I think that's the whole point of ocLazyLoad is just to load it only when it's needed and load it only once, there must be something else wrong with the code – Ade Mar 11 '16 at 11:50

0 Answers0