2016-12-03 72 views
0

我試圖創建儀表板,其中儀表板是抽象狀態,子儀表板是儀表板的下一個子狀態。單擊儀表板上的任何ui-sref顯示li活動的ul li

enter image description here

這裏查看用戶的詳細信息,使用去狀態dashboard.tables。但問題是,html元素li沒有打開/變得活躍。

enter image description here

雖然狀態改變時,即特定的元素沒有得到積極的是在​​數據表

enter image description here

在上圖中,我已經做了手動開啓,只是說明我的查詢。 這是任何狀態的點擊/改變都應該在側面菜單中激活並顯示爲激活狀態。任何幫助將是巨大的

這裏是我的代碼,

<li class="has_sub"> 
<a href="" class="waves-effect waves-light"><i class="md md-view-list"></i><span> Data Tables </span><span class="pull-right"><i class="md md-add"></i></span></a> 
     <ul class="list-unstyled"> 
      <li ui-sref-active='{"active": "dashboard" }' ><a ui-sref="dashboard.tables">Tables</a></li> 
     </ul> 
     </li> 

這裏是我的路線

r.state("dashboard",{abstract:"true",templateUrl:"partials/dashboard.html"}) 
    r.state("dashboard.subdashboard",{url:"/dashboard",templateUrl:"partials/subdashboard.html"}) 
    r.state("dashboard.tables",{url:"/tables",templateUrl:"partials/tables.html"}); 

另外,作爲由LouieAlmeda說,我已經寫了,但它不會工作我刪除它。 也納克級的我已經測試過,但沒有用

+1

雖然它的一個重複的問題,很多人是不能夠解決這個問題,因爲是不同的方法來做。嘗試這個ng-class =「{active:$ state.includes('nameofyourstate)}」給你的li –

+0

感謝@NitinAgarwal爲你的迴應。是的,我也試過ng-class,ui-sref-active,賦值給$ scope。$ state = $ state in controller和$ rootcope。$ state = $ state在運行但沒用。任何幫助將是偉大的 – ANK

+0

我有一個類似的問題,關於在抽象狀態添加一個類的解決方案: http://stackoverflow.com/questions/38091312/ui-sref-active-on-an-abstract-state 我希望這可以幫助 –

回答

0

可以嘗試:

<li ui-sref-active='{"active": ".dashboard" }' ><a ui-sref="dashboard.tables">Tables</a></li> 
+0

謝謝@Louie阿爾梅達。我已經嘗試過,但它不適合我。 – ANK