问题描述
我目前正在实施这样的事情( AngularJS )
I am currently looking to implement something like this (AngularJS):
$routeProvider
.when('/root/:controllerName/blah/:blahId/blah/:blah', {
templateUrl: '/tmpl/:controllerName/blah/partials/:blah' + '.html',
controller: ':controllerName' + 'Ctrl'
})
这可能是过于复杂(与'胡说,胡说,胡说'),但我想,以确保它是明确的。
This is probably overly complicated (with the 'blah, blah, blah') but I wanted to make sure it is clear.
在概括地说,我的目标来完成类似的(足够的)如何微软MVC使用其路由控制器的东西 - 换句话说,非常自主的:
In a nutshell, I'm aiming to accomplish something similar (enough) to how Microsoft MVC employs their routing to controllers -- in other words, very autonomous:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
在那之后,我打算LazyLoad控制器(我已经),但必须是(希望)与惰性加载兼容。
After that, I intend to LazyLoad the controller (which I have already), but this needs to be (hopefully) compatible with LazyLoading.
有没有人有这种做法的成功,知道有什么资源,或者有关于如何做到这一点任何想法?
Has anyone had success with this approach, know of any resources, or have any ideas about how to accomplish this?
- preThanks
--PreThanks
推荐答案
我不认为你将能够解决这一使用的 ngRoute 但是我觉得 ngInclude 应能够帮助:
I do not think you will be able to resolve this using ngRoute but I think ngInclude should be able to help:
HTML
<div class="slide-animate-container">
<div ng-include="template.url"></div>
</div>
控制器
$scope.template.url = "";//some dynamic rules
下面是关于这角文档的链接:
Here is a link to angular documentation on this:
这篇关于AngularJS:高动态路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!