if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
} else {
//There isn't an app that handle your intent
}
$stateProvider
.state('dashboard', {
url:'/dashboard',
controller: 'MainCtrl',
templateUrl: 'views/dashboard/main.html'
})
.state('dashboard.exchange',{
templateUrl:'views/dashboard/exchange.html',
controller: 'ExchangeCtrl',
url:'/exchange/{exchangeId:[0-9]}',
})
.state('dashboard.exchange.module',{
templateUrl:'views/dashboard/exchangeModule.html',
controller: 'ExchangeModuleCtrl',
url:'/module/{exchangeModuleHostName}',
})
正确地正确路由到MainCtrl '/dashboard'
正确路由到ExchangeCtrl '/dashboard/exchange/1'
错误地路由到 ExchangeCtrl 为什么没有第三个到ExchangeModuleCtrl的URL路由?我该如何解决这个问题?
答案 0 :(得分:1)
如果我们想要上一个子状态:'dashboard.exchange.module'
完全替换其父'dashboard.exchange'
的内容,我们必须选择:
我们可以将ui-view=""
放入父根<element>
。有a working example。这将是'dashboard.exchange'
州模板 views / dashboard / exchange.html :
<div ui-view="">
<h3>dashboard.exchange</h3>
<br />
context just for the state: <b>dashboard.exchange</b>
</div>
最重要的是根 <div ui-view="">
,因为孩子将完全取代父母。
在这种情况下,我们将跳过父级。我们将直接针对盛大的父母&#39;仪表板&#39;。有a working plunker。这里我们使用绝对命名来定位祖父母未命名视图:
.state('dashboard.exchange.module',{
views : {
'@dashboard' : {
templateUrl:'views/dashboard/exchangeModule.html',
controller: 'ExchangeModuleCtrl',
},
},
url:'/module/{exchangeModuleHostName}',
})
检查这些类似的Q&amp;有关绝对命名的更多详细信息:
如果我们想要遵循标准方法 - 有a working example
您的代码应该按原样运作。
最重要的是,每位家长必须包含儿童的目标: ui-view=""
,例如:
<div ui-view=""></div>
视图views/dashboard/main.html
必须包含子状态的目标 'dashboard.exchange'
<div >
<h2>dashboard</h2>
<br />
<div ui-view=""></div> // this is for child exchange
</div>
视图views/dashboard/exchange.html
必须包含子状态的目标 'dashboard.exchange.module'
<div >
<h3>dashboard.exchange</h3>
<br />
<div ui-view=""></div> // this is for child module
</div>
检查here