ocombe / ocLazyLoad

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

Is there a way to load files from other state to another state? #407

Open emjey23 opened 7 years ago

emjey23 commented 7 years ago

Example is I had a state looks like this that has many files, is there any way/solution that I can load this same files to another state such as state("editAdmin")?

My other question is there another way that I can minimize or prettify my codes like instead of typing all individual files, $ocLazyLoad.load will read files inside a folder.

`$stateProvider.state("admin", {
    url:"/admin",
    controller: "AdminController",
    templateUrl: "html/admin/adminHome.html",
    resolvePolicy: {loadMyCtrl : {when: "LAZY", async: "WAIT"}},
    resolve: {
        loadMyCtrl: ['$ocLazyLoad', function($ocLazyLoad){
            return $ocLazyLoad.load(['css/bootstrap.min.css', 'css/bootstrap-responsive.min.css',
            'css/fullcalendar.css', 'css/matrix-style.css', 'css/matrix-media.css',
            'css/jquery.gritter.css', 'js/excanvas.min.js', 'js/jquery.ui.custom.js',
            'js/bootstrap.min.js', 'js/jquery.flot.min.js', 'js/jquery.flot.resize.min.js',
            'js/jquery.peity.min.js', 'js/fullcalendar.min.js', 'js/matrix.js',
            'js/matrix.dashboard.js', 'js/jquery.gritter.min.js', 'js/matrix.interface.js',
            'js/matrix.chat.js', 'js/jquery.validate.js', 'js/matrix.form_validation.js',
            'js/jquery.wizard.js', 'js/jquery.uniform.js', 'js/select2.min.js',
            'js/matrix.popover.js', 'js/jquery.dataTables.min.js', 'js/matrix.tables.js'

            ])
        }]
    }
    })

    .state("editAdmin", {
    url:"/editAdmin/:id",
    controller: "EditAdminController",
    templateUrl: "views/",
    })`