javascript - lazy-loaded states with ui-router -


my lazy loading library this: oclazyload , i'm attempting use ui-router.

i have routes declared in 2 separate files concatenated in build process. here concatenated output is:

angular.module('asdf').config(['$stateprovider', '$locationprovider', '$urlrouterprovider', function($stateprovider, $locationprovider, $urlrouterprovider) {      $urlrouterprovider.otherwise('/');     $locationprovider.hashprefix('!');      $stateprovider         .state('root', {             url: '/',             templateurl: 'views/static/welcome.html'         }); }]);  angular.module('asdf').config(['$stateprovider', function($stateprovider) {     $stateprovider         .state('cohort-definition-editor', {             url: '/cohort-definition-editor',             templateurl: 'components/cohort-definition-editor/mui/cohort-definition-editor.html',             controller: 'cdecontroller',             data: {                 pagetitle: "cohort definition editor",                 subtitle: "cohort definition editor",                 category: "apps"             },             params: {                 _form_linkid: undefined             },             resolve: {                 dep: ['$oclazyload', function($oclazyload) {                     // console.log('test');                     return $oclazyload.load([                         'components/cohort-definition-editor/mui/cohort-definition-editor.min.js',                         'components/cohort-definition-editor/mui/cohort-definition-editor.min.css'                     ]);                 }]             }         }); }]); 

(a lot of second file autogenerated, repetition intentional.)

my problem this: cannot refresh page when on lazy-loaded state. start pageload here: http://127.0.0.1:9001/#!/ , click link ui-sref="cohort-definition-editor" loads url: http://127.0.0.1:9001/#!/cohort-definition-editor (with proper state/html fragment/etc). if refresh page, instead greeted "empty" state. normally, views/static/welcome.html displayed default nothing should have cohort-definition-editor html fragment displayed, , url still correct one.

i've added bunch of watchers ui-router events , none of them fire on pageload. i've tried adding console.log statement (see above, commented in resolve section) , not fire, leading me believe wrong di on pageload. it's not erroring out though, it's difficult trace.

is there better way lazy-load ui-router states, or doing wrong? reference, first learned of oclazyload here similar thing , works.

as luck have it, if refresh page state has required param isn't set default value (ie, have param set undefined) route cannot loaded requires param. result best thing here make param have default value.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -