ui-sref-active在抽象状态

时间:2016-06-29 05:48:28

标签: javascript angularjs angular-ui-router

我有这些路线:

  • .account /:email
  • .account.home /:email
  • .account.personal /:email / personal
  • .account.settings /:email / settings

.account是一个抽象状态,.account.home是它将要进入的默认状态。

现在如果我有这个链接,ui-sref-active在导航时添加一个类,我会做类似的事情

<a ui-sref-active='active' ui-sref='.account.home({email: account.email})'></a>

右键单元在单击时被active类设置(这是预期的),但是如果我点击.account.personal它将被删除,因为它不是{{1}的子元素1}}但.account.home

的孩子

即使我选择了不同的路线,如何设置.account保持有效至ui-sref-active以上?但我无法将它链接到抽象状态,因为我们无法导航到抽象状态?

1 个答案:

答案 0 :(得分:1)

你必须使用像<head> <link rel="stylesheet" type="text/css" href="mystyle.css"> </head>

这样的ui-sref-active
ng-class

重要的是这个:

<a ui-sref-active='{"active": ".account({email: account.email})" }' ui-sref='.account.home({email: account.email})' >

告诉ui-router在当前状态为{"active": ".account({email: account.email})" }时设置active类,因此它现在正在查看抽象状态.account({email: account.email})而不是.account

相关问题