Using AngularJS routing and loading controllers on demand using requirejs

后端 未结 1 1109
一向
一向 2020-12-31 09:04

I\'m trying to use AngularJS and RequireJS in combination. I would like to use the $routeProvider service and avoid having to load all the controllers for my vi

1条回答
  •  囚心锁ツ
    2020-12-31 10:05

    You can find the solution here

    You need to define a resolve property on each route and assign it a function that returns a promise. The function can dynamically load the script contains the target controller and resolve the promise once the loading is complete. In this article, Dan Wahlin shows how to use convention over configuration to have more practical routing.

    0 讨论(0)
提交回复
热议问题