Is possible to add controller on ui-router lazyload function

34 views Asked by At

I'm trying to lazyload my controller with pure ui-router lazyload function as : I've tried the two follow exemples

1.

   $stateProvider.state('profile', {
                    url: '^/profile',
                    template: view,
                    controller:'profileController',
                    security: true
                    , lazyLoad: function ($transition, $state) {
                        angular.module('profileModule').controller('profileController', require('./components/profile/controller.js')     ;                   
                     }
                });

In this exemple when load the state the error of controller no registred appear, even tho the docs of ui-router says lazyload functions is called before the state change.

2.

  $stateProvider.state('profile', {
                    url: '^/profile',
                    template: view,
                    security: true
                    , lazyLoad: function ($transition, $state) {
                         angular.module('profileModule').controller('profileController',require('./components/profile/controller.js');
                        $state.controller = 'profileController';

                     }
                });

In this no error is shown on console, but the controller is not attached to the state.

Any regards on that? and no i cant use oclazyload for reasons i cant explain :/ Please haaaaaalp

0

There are 0 answers