我已经开始采用了棱角分明的UI路由器,我试图找出如何有多个URL指向一个单一的国家。例如:
/ [机构/ 12354 /概述// retyrns相同的页面作为/组织/概述
我的$状态提供当前设置像这样的东西,它不清楚我如何在别名'/组织/概述路线滑,使得它正确地从组织父母继承。
.STATE('组织',{ 摘要:真实, 网址:'/ [机构/:ORGID', templateUrl:/client/navigation/main.html}).STATE('org.overview',{ 网址:'/概览, templateUrl:/client/overview/overview.html', 控制器:'OverviewCtrl})
解决方案
这可以通过使用达到()时,就像这样:假设这是国家的,你想点与多个网址。
.STATE('app.home', { 网址:'/家, templateUrl:home.html做为', 控制器:'homeCtrl })
然后在配置中,可以使用时,()如下:
angular.module('对myApp',[]) 的.config($ urlRouterProvider){ $ urlRouterProvider.when(/主页,['$状态,$匹配',函数($状态,$匹配){ $ state.go('app.home'); }]);}
聪明一样可以添加指向同一状态多个网址。
I have started using angular's ui-router, and I am trying to figure out how to have multiple URLS refer to a single state. For example:
/orgs/12354/overview
//retyrns the same pages as
/org/overview
My $state provider is currently set with something like this, and its unclear to my how to slip in the alias '/org/overview' route such that it properly inherits from the 'org' parent.
.state('org', {
abstract: true,
url: '/orgs/:orgID',
templateUrl: '/client/navigation/main.html'
})
.state('org.overview', {
url: '/overview',
templateUrl: '/client/overview/overview.html',
controller: 'OverviewCtrl'
})
解决方案
This can be achieved using the when(), like this: Suppose this is the state, you want to point to with multiple urls.
.state('app.home',
{
url: '/home',
templateUrl: 'home.html',
controller: 'homeCtrl'
})
then in the config, you can use when() as follows:
angular.module('myApp', [])
.config($urlRouterProvider){
$urlRouterProvider.when(/homepage, ['$state','$match', function ($state, $match) {
$state.go('app.home');
}]);
}
Like wise you can add multiple urls pointing to same state.