Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS - Multiple 'ui-sref' in single 'ui-sref-active'

HTML:

<!-- Order -->
<li ui-sref-active="active">
    <a ui-sref="order" class="main_link">
        <i class="fa fa-shopping-cart"></i>Order
    </a>
    <a ui-sref="order/create"><span class="plus">+</span></a>
    <div class="clearfix"></div>
</li>

I want to add class="active" on <li>.

Whenever click on <a ui-sref="order/create"><span class="plus">+</span></a> this, that time class="active" add on <li>.

BUT

click on <a ui-sref="order" class="main_link"><i class="fa fa-shopping-cart"></i>Order</a> that time class="active" not add on <li>.

Your help would be appreciated.

like image 557
Dr.Tricker Avatar asked Aug 07 '26 05:08

Dr.Tricker


1 Answers

The way the ui-router is currently implemented it is not possible to do that. You can't specify for which particular ui-sref the ui-sref-active will be activated. That being said, it should be easier to adjust your template to wrap those links in such a way that you can have one ui-sref-active per one ui-sref. At least easier than adjusting ui-router behaviour.

like image 173
tomastrajan Avatar answered Aug 09 '26 19:08

tomastrajan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!