2
我使用angular-js和ui-route構建了菜單鏈接。用於嵌套狀態的ui-sref-active
<li ui-sref-active="active">
<a ui-sref="dashboard" title="Dashboard"><i class="fa fa-lg fa-fw fa-home"></i> <span class="menu-item-parent">Dashboard</span></a>
</li>
它工作成功,但如果我進入子狀態,例如dashboard.view,則鏈接不會更改爲活動。
你可以通過下面的URL檢查。
在http://angular-ui.github.io/ui-router/sample/#/contacts中,聯繫人選項卡已激活,但是 http://angular-ui.github.io/ui-router/sample/#/contacts/1,聯繫人選項卡未激活。
所以我怎樣才能建立活動的嵌套狀態的HTML鏈接?
作爲便箋,今天我發現了[includedByState](http://angular-ui.github.io/ui-router/site/#/api/ui.router.state.filter:includedByState)過濾。該代碼會更難看一點,但是您可以使用該代碼或[$ state.includes](http://angular-ui.github.io/ui-router/site/#/api/ui.router .state。$ state)有條件地將你的類應用於標記中。 –