嗨,
我目前正在寻求实现这样的东西(AngularJS):
$routeProvider
.when('/root/:controllerName/blah/:blahId/blah/:blah', {
templateUrl: '/tmpl/:controllerName/blah/partials/:blah' + '.html',
controller: ':controllerName' + 'Ctrl'
})
这可能过于复杂(带有“blah,blah,blah”),但我想确保它是清楚的。
简而言之,我的目标是完成与 Microsoft MVC 如何使用其到 Controller 的路由类似(足够)的事情 - 换句话说,非常自主:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
之后,我打算 LazyLoad Controller (我已经这样做了),但这需要(希望)与 LazyLoading 兼容。
是否有人通过这种方法取得了成功,了解任何资源,或者对如何实现这一目标有任何想法?
--谢谢
最佳答案
我认为您无法使用 ngRoute 解决此问题,但我认为 ngInclude 应该能够提供帮助:
HTML
<div class="slide-animate-container">
<div ng-include="template.url"></div>
</div>
Controller
$scope.template.url = "";//some dynamic rules
这是有关此问题的 Angular 文档的链接:
关于javascript - AngularJS:高度动态路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23705350/