如何在ng-repeat中使用ng-class为每个it-div设置类

  • **this is my home page ** i am showing data coming from mysql to card but is have same tag color i.e class="tag tag-pill tag-danger" i am using ng-class={{hos.class}} /*class is a coloumn in table */

    <div class="col-md-5" ng-repeat="hos in ho">
         <div class="col-md-6">
             <div class="card"> <img class="img-fluid" ng-src="{{hos.img}}" alt="">
                  <div class="card-img-overlay"> <span ng-class=" ">{{hos.tag}}</span> </div>
                  <div class="card-block">
    <div class="news-title">
    <h2 class=" title-small"><a href="#">{{hos.topic}}</a></h2>
    </div>
    <p class="card-text"><small class="text-time"><em>{{hos.time}}</em></small></p>
    </div>
    </div>
    </div>
    </div>
    

try ng-class="hos.tag" or class="{{hos.tag}}"

You are using ng-class incorrectly: its expression comprises of an object where each property is a class and the value is an expression to evaluate to conditionally apply that class when truth.

For example ng-class="{'active': button.active}"

Hopefully, this fiddle will help: jsFiddle