Alexmelyon
Alexmelyon

Reputation: 1239

Conditions in class attribute of element in Angular.js

I use this code:

<buton class="audio-button {{audio.isPlaying && 'active'}}"></button

Is this practice are normal or it will make problems?

Upvotes: 0

Views: 30

Answers (1)

Matt Way
Matt Way

Reputation: 33141

I assume that you want to add the active class if audio.isPlaying is true. In that case, you should be using ng-class.

<button class="audio-button" ng-class="{ 'active' : audio.isPlaying }"></button>

You can read more about it here

Upvotes: 2

Related Questions