Himmators
Himmators

Reputation: 15006

How to apply a class in angular based on a value in the scope?

in angular I have a function that looks like this:

$scope.memberselect =function(myname){
    $scope.member = (myname);
 };

I try to set a class based on $scope.member. LIke this:

 ng-class="{expanded: member = mathieu}"

I want the node with the attribute to get the value expanded if $scope.member = mathieu.

Upvotes: 0

Views: 72

Answers (1)

AlwaysALearner
AlwaysALearner

Reputation: 43947

ng-class="{ 'expanded' : member == 'mathieu' }" 

or

ng-class="{ 'expanded' : true }[member == 'mathieu']"

Upvotes: 2

Related Questions