2017-02-08 11 views
0

によるCSSのアクティブセレクタ私はクラス名を設定したいと思います。そうのようなNG-クラスによって活性セレクター:あなたができる変数の角度セット:NGクラス

ng-class="{'active':true}" 

ng-class='{"className:active" : true}'

+0

あなたはそうすることができるとは思わないでください。あなたのユースケースを説明してください、あなたはそれをやりたいのですか? '.focus()'を設定すると、アクティブな要素になります。 – devqon

答えて

0

を試してみてくださいあなたの:active擬似クラスとまったく同じプロパティを持つクラスを作成することによってそれを "偽造"する必要があります。

0

はこれを試しますI yを推測

<!-- add a class to the first item --> 
<ul> 
    <li ng-class="{ 'text-success': $first }" ng-repeat="item in items">{{ item.name }}</li> 
</ul> 

<!-- add a class to the last item --> 
<ul> 
    <li ng-class="{ 'text-danger': $last }" ng-repeat="item in items">{{ item.name }}</li> 
</ul> 

<!-- add a class to the even items and a different class to the odd items --> 
<ul> 
    <li ng-class="{ 'text-info': $even, 'text-danger': $odd }" ng-repeat="item in items">{{ item.name }}</li> 
</ul> 

for more options

+0

Doestは私のクラスの:activeセレクタを設定しているようです –