0

I have an issue with the routes and controller. If I have a route like below this->

.state('dashboard/profile', { url: '/dashboard/profile', parent: 'common', //templateUrl: '/app/dashboard/dashboard.html', template: '<div><h4>dashboard/profile</h4></div>', controller: 'ProfileCtrl' })
Now as I will be having many routes,I want to load all the routes inside dashboard only after the user reaches dashboard.html page.If I follow as above I will have to load all the routes even when not needed.For example: The above profile URL will be only hit once user is authenticated and authorized for dashboard and only then the user will reach dashboard,but I will have to load the routes controllers here which are not needed.
I want the internal routes for dashboard to be separated and called only when dashboard is visited by user. How can I avoid loading unnecessary controllers and routes?

KillABug
  • 1,414
  • 6
  • 34
  • 69
  • If I do understand your issue properly, you would like to have some kinde of lazy loading? if yes, please, take a look at this comprehensive description http://stackoverflow.com/a/27754025/1679310 – Radim Köhler Mar 16 '15 at 09:57
  • No what I want to know is can I keep the routes inside a specific URL separate. That is I want anything after dashboard example `dashboard\profile` or `dashboard\deals` have routes defined separately in a file and loaded at the time when dashboard loads – KillABug Mar 16 '15 at 10:02
  • Sorry then... my approach is about lazy loading controllers or templates... not whole states. But I guess, that the latest angualr router is very smart and is capable of that. you should check this https://www.youtube.com/watch?v=h1P_Vh4gSQY... to get some idea about its features – Radim Köhler Mar 16 '15 at 10:05
  • @RadimKöhler Thank you,actually as the states would go on increasing it would make the code cluttered and reduce readability,thats the concern.Also it may load dependencies no needed.Hence the query! **Also couldn't find any relevant examples on web.** – KillABug Mar 16 '15 at 10:24

0 Answers0