2016-12-11 6 views
1

私はJSONデータを含む角度配列を持っています。要素の1つはイオンアイコンの名前です。私は要素をループするためにng-repeatを使用しており、各繰り返しでイオンアイコン名を動的に更新したいと考えています。この例では角度配列要素のHTMLクラス名

<div class = "row" ng-repeat="item in serviceList" ng-switch on="$index % 3"> 
    <div class = "col text-center" ng-switch-when="0"> 
     <i class = "services icon ion-laptop">{{ serviceList[$index].IconName }} </i> 
    </div> 

    <div class = "col text-center" ng-switch-when="0"> 
    <i class = "services icon ion-laptop">{{ serviceList[$index+1].IconName }}</i> 
    </div> 

I手動イオンラップトップを設定したが、私は更新するために、それぞれserviceList [$インデックス] .IconNameとserviceList [$インデックス+ 1] .IconNameを}}使用しますアイコン。上記のコードはアイコン名の文字列を出力しますが、HTMLクラスタグの内部に配置する方法はわかりません。何かご意見は?

答えて

0
<div class = "row" ng-repeat="item in serviceList" ng-switch on="$index % 3"> 
    <div class = "col text-center" ng-switch-when="0"> 
     <i class = "services icon {{ serviceList[$index].IconName }}"> </i> 
    </div> 

    <div class = "col text-center" ng-switch-when="0"> 
    <i class = "services icon {{ serviceList[$index+1].IconName }}"></i> 
    </div> 

ない大きな問題...ではなく、 `class`を控え

+0

' NG-class'をGO –

関連する問題