ksk
ksk

Reputation: 307

My Ng-Class not working

I have built in Btn style, so I just want to customize it a bit as new style as

<style>
    .btn.activeother {
        color: #fff;
        background-color:Red;
    }
</style>

and want to use it like this

       <div  class="btn-group col-md-10 segmented-label" >
       <label  ng-repeat="list in inputarray"  name="{{assessmenttype}}" 
       ng-model="$parent.selecteditem"  ng-class="{'btn activeother':selecteditem==list.score && selecteditem!= normalscore }"  btn-radio="{{list.score}}">{{list.name}}</label>
       </div>

So here I will pass normalscore as 2 and I have 3 items each of which contain list score as 1,2,3 and list name as a, b, c

so I want my costume css class .btn.activeother to be set using ng-class with the logic such that if selected item score is same as normal I want .btn.activeother to be applied instead of default btn active

so please help me in solving this issue currently my ng-class is not handling this please let me know what is correct?

Upvotes: 4

Views: 201

Answers (1)

Sudharsan S
Sudharsan S

Reputation: 15403

Initaially defined the class .btn and conditional check only for .activeother class

<div  class="btn-group col-md-10 segmented-label" >
       <label  ng-repeat="list in inputarray"  name="{{assessmenttype}}" 
       ng-model="$parent.selecteditem" class="btn" ng-class="{'activeother':selecteditem ==list.score && selecteditem != normalscore }"  btn-radio="{{list.score}}">{{list.name}}</label>
       </div>

Upvotes: 2

Related Questions