ng-class
CSSファイルから乗算ルールを設定するために呼び出されるディレクティブを使用しようとしています。ここにコードの一部があります
<div class="filterToggleBtn thumbnail"
ng-class="{ filterToggleBtnSide notificationColor:notificationState }">
</div>
変数filterToggleBtnSide
とnotificationColor
、CSS ルールの文字列名が含まれています。
変数notificationState
セットtrue
またはfalse
.
filterToggleBtnSide
問題のポイントは、常にrule を使用する方法であり、その場合にnotificationColor
のみnotificationState
真になります。
私は以下のようなコードを作ろうとしていました
<div class="filterToggleBtn thumbnail"
ng-class="{ filterToggleBtnSide && notificationColor:notificationState }">
</div>
<div class="filterToggleBtn thumbnail"
ng-class="{ filterToggleBtnSide, notificationColor:notificationState }">
</div>
<div class="filterToggleBtn thumbnail"
ng-class="{ filterToggleBtnSide:true, notificationColor:notificationState }">
</div>
最後のサンプルでは、2 番目の式のみが機能しています。誰かが助けてくれれば、私は非常に感謝します;Dありがとう