angularjs - ngRouter to ui-router -


i purchased angularjs template using build application, noticed ngrouter used instead of ui-router prefer , more familiar with.

i tried including ui-router , changing routes , worked, there code in routes still not understand , not know put, old route dashboard:

$routeprovider.when("/dashboard", {     templateurl: "views/dashboard.html",     resolve: {         deps: ["$oclazyload", function(a) {             return a.load([jqload.c3, jqload.sparkline])             .then(function() {                 return a.load({                     name: "app.directives",                     files: ["scripts/lazyload/directives/sparkline.directive.js"]                 })             })             .then(function() {                 return a.load("angular-c3");             })             .then(function() {                 return a.load("easypiechart");             })          }]     } }); 

this changed to:

.state('admin.dashboard', {     url: '/dashboard',     views: {         'content@': {             templateurl: '/_admin/views/dashboard.html',             controller: 'dashboardctrl'         }     } 

as can see there great portion of code missing affects functionality of dashboard. question using ui-router place code in resolve:

resolve: {         deps: ["$oclazyload", function(a) {             return a.load([jqload.c3, jqload.sparkline])             .then(function() {                 return a.load({                     name: "app.directives",                     files: ["scripts/lazyload/directives/sparkline.directive.js"]                 })             })             .then(function() {                 return a.load("angular-c3");             })             .then(function() {                 return a.load("easypiechart");             })          }]     } 

i've never come across resolve before, quite new angularjs , dunno section after switching ui-router.

the resolve property tells angularjs callbacks within must complete before state displayed. ngrouter has this, ui-router. here's reading you.

this code should work:

.state('admin.dashboard', {     url: '/dashboard',     views: {         'content@': {             templateurl: '/_admin/views/dashboard.html',             controller: 'dashboardctrl'         }     },     resolve: {         deps: ["$oclazyload", function(a) {             return a.load([jqload.c3, jqload.sparkline])             .then(function() {                 return a.load({                     name: "app.directives",                     files: ["scripts/lazyload/directives/sparkline.directive.js"]                 })             })             .then(function() {                 return a.load("angular-c3");             })             .then(function() {                 return a.load("easypiechart");             })          }]     } }) 

Comments