0

次のような非常に単純なAngularコードがいくつかあります...

<div ng-repeat="message in data.messages" ng-class="'conversationCard-' + 
message.type"></div>

動作しますが、結果の出力は次のようになります....

<div ng-repeat="message in data.messages" ng-class="'conversationCard-' + 
message.type" class="ng-scope conversationCard-phone"></div>

問題は、私のクラスが ng-scope で始まり、このように見える私の css セレクターを壊していることです..

[class^="conversationCard"]

angular を取得して ng-scope を削除する方法、または少なくともクラス宣言の最後に配置する方法はありますか?

4

2 に答える 2

1

css 経由でそのクラスにアクセスするかどうかは問題ではありません。

div.conversationCard-phone{
    //css stuff
}

クラスの CSS で属性を指定する機能を使用している理由がわかりません。説明した方法は、それを行う一般的な方法です。属性セレクターを使用している理由を詳しく説明していただけますか?

編集

あなたのhtmlをに変更してください

<div ng-repeat="message in data.messages" ng-class="message.type" class="conversationCard"></div>

そのように処理されます

<div ng-repeat="message in data.messages" ng-class="message.type" class="ng-scope conversationCard phone"></div>

だからあなたのCSSでできること

div.conversationCard{
    //css stuff
}

電話を分離したい場合は、次のようにします。

div.conversationCard.phone{
    //css stuff
}
于 2012-12-24T21:34:10.700 に答える
-1

ng-class を使用して void はどうですか。このようなクラスを使用するだけです

<div ng-repeat="message in data.messages" class="conversationCard-{{message.type}}"></div>
于 2012-12-24T21:41:08.877 に答える