我完全是AngularJS的新手。只想用$ routeProvider尝试相对URL。
下面是这种情况:
我有一个 “编辑” 页面时,ASP.NET MVC链接页面将是:
http://localhost/Workflow/Edit
所以ASP.NET MVC控制器是“WorkflowController “并且动作是”编辑“。对于谐音我有控制的动作,每个返回的局部视图这样的:
public ActionResult WorkflowTransition()
{
return PartialView("WorkflowTransition");
}
public ActionResult WorkflowTransitionApprovers()
{
return PartialView("WorkflowTransitionApprovers");
}
以下是AngularJS模块配置 - 请注意:一个PartialView(如上所述)被称为每一条路线的(这可能是不正确的):
$routeProvider.when('Workflow/WorkflowTransition', {
templateUrl: '/Workflow/WorkflowTransition',
controller: 'transitionCtrl',
});
$routeProvider.when('Workflow/WorkflowTransitionApprovers', {
templateUrl: '/Workflow/WorkflowTransitionApprovers',
controller: 'approversCtrl'
$routeProvider.otherwise({
redirectTo: '/'
});
注:我有不指定的以下任一:
$ locationProvider.html5Mode(假);
OR
$ locationProvider.html5Mode(假).hashPrefix( '!');
的HREF链接指定这样的:
<a href="#/Workflow/WorkflowTransition">{{workflow.Identifier}}</a>
这会产生这种形式的链接:
http://localhost/Workflow/Edit#/Workflow/WorkflowTransition
这显然是错误的(和点击链接并不可能做任何事情因为浏览器试图导航到哈希),所以我尝试了领先的'/',但也没有运气:
<a href="/#/Workflow/WorkflowTransition">{{workflow.Identifier}}</a>
如果我直接导航部分,即http://localhost/Workflow/WorkflowTransition
,浏览器按原样呈现html(以及angularjs大括号{{}})。
我的问题是:AngularJS如何处理'#'或'#!'当涉及到确定相对URL?对于例如做这条路线(假设我收工/编辑部分从URL中的锚标记):
$routeProvider.when('Workflow/WorkflowTransition',
匹配的网址:
http://localhost/Workflow/#WorkflowTransition
?
它是否从URL中删除'#',然后根据$ routeProvider.when()中的URL模式进行检查?
有人可以建议相关网址的正确路线吗?
谢谢你。 – Faredoon 2013-05-21 00:07:21