Loading angular js internal routes and controllers

好久不见. 提交于 2019-12-25 04:26:28

问题


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?

来源:https://stackoverflow.com/questions/29073389/loading-angular-js-internal-routes-and-controllers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!