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?

4
  • 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 stackoverflow.com/a/27754025/1679310 Commented Mar 16, 2015 at 9: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 Commented Mar 16, 2015 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 youtube.com/watch?v=h1P_Vh4gSQY... to get some idea about its features Commented Mar 16, 2015 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. Commented Mar 16, 2015 at 10:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.