我有这些路线:
.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
以上?但我无法将它链接到抽象状态,因为我们无法导航到抽象状态?
答案 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