我正在使用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;。
答案 0 :(得分:3)
Tricky使用这样的三元运算符
<td>
{{obj.IsActive ? 'Approved ' : 'Pending'}}
</td>