ocombe / ocLazyLoad

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

How to resolve multi function in UI-Router with ocLazyLoad #300

Open essivision opened 8 years ago

essivision commented 8 years ago

Hi

I want to resolve multi function and pass to controller with ocLazyLoad.

.state('admin.editUser',{
                url: "/users/:id/edit",
                templateUrl: "app/modules/user/views/userform.html",
                ncyBreadcrumb: {
                    label: 'New User',
                    parent:'admin.users'
                },
                data: {
                    permits: {
                        withOnly: 'edit_user'
                    }
                },
                controller:'UserEditCtrl',
                resolve: {
                    dep: ['$ocLazyLoad',
                        function( $ocLazyLoad ){
                            return $ocLazyLoad.load(['dropzone','RoleServiceModule','UserServiceModule']).then(
                                function(){
                                    return $ocLazyLoad.load(['app/modules/user/controllers/UserEditCtrl.js']);
                                }
                            );
                        }],
                    resolvedItems:['dep','UserService','$stateParams',
                        function(dep,UserService,$stateParams) {
                            return {
                                user:function() {
                                    return UserService.show($stateParams.id).then(function(data) {
                                        return data;
                                    });
                                },
                                roomNo:function(data) {
                                    return "100";
                                }
                            };
                        }]
                }
            })