如何比较angularjs中ng-repeat的值

时间:2016-12-16 10:36:08

标签: javascript jquery angularjs html-table

我正在使用ng-repeat获取数据并将其填入表中,这是我的表

<table class="table table-bordered table-hover">
   <thead>
      <tr>
         <th>
            Sr. no.
         </th>
         <th>
            Title
         </th>
         <th>
            Image
         </th>
         <th>
            Category
         </th>
         <th>
            PostedOn
         </th>
         <th>
            Created By
         </th>
         <th>
            Status
         </th>
         <th>
            Active Blog
         </th>
      </tr>
   </thead>
   <tbody>
      <tr ng-repeat="obj in PostedBlogList | filter:searchText" ng-show="PostedBlogList.length">
         <td>{{$index+1}}</td>
         <td><a ng-href="{{'//'+obj.PageUrl }}">{{obj.Title}}</a></td>
         <td>
            <img style="width:90px" ng-show="obj.Image" src="{{obj.Image}}">
            <img style="width:90px" ng-show="!obj.Image" src="/images/mail.png">
         </td>
         <td>
            {{obj.CategoryName}}
         </td>
         <td>
            {{obj.CreatedDate}}
         </td>
         <td>
            {{obj.FirstName}}({{obj.UserType}})
         </td>
         <td>
            {{obj.IsActive}}
         </td>
         <td>
            <button class="btn btn-primary waves-effect waves-light" ng-click="ToActiveBlog(obj.Id)" ng-bind="btnactivate" type="submit" value="Activate"></button>
         </td>
      </tr>
      <tr ng-show="PostedBlogList.length==0">
      </tr>
   </tbody>
</table>

在状态行中,我收到状态true {{obj.IsActive}}

那么如何检查{{obj.IsActive}}是否为真,然后设置&#34;已批准&#34; 如果{{obj.IsActive}}为假,则设置值&#34;待定&#34;。

1 个答案:

答案 0 :(得分:3)

Tricky使用这样的三元运算符

 <td>
   {{obj.IsActive ? 'Approved ' : 'Pending'}}
 </td>