1

I am trying to dynamically change the class name when a showPending function called . I don't know how to achieve that through angular js.

<li data-match-route="pending" ng-class='menuactive'><a href="javascript:void(0)" ng-click="showPending()" >Pending</a></li>

2 Answers 2

2

You can specify what class should be applied with an expression, as explained in the docs; AngularJS: API: ngClass

<li data-match-route="pending"
    ng-class="{menuactive: expression}">
      <a href="javascript:void(0)" ng-click="showPending()" >Pending</a>
</li>

set expression in your controller in your showPending function, and the css class will be updated accordingly.

Sign up to request clarification or add additional context in comments.

Comments

0

You can use ng-class directive for that. In your function which is getting called set an expression named "value" as true or false, which you will use in ng-class as mentioned in following example.

    <li data-match-route="pending" ng-class="{menuactive:value}">
<a href="javascript:void(0)" ng-click="showPending()" >Pending</a></li>

2 Comments

How is this different from the other answer?
I saw it late. Refresh issues. :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.