gpt4 book ai didi

javascript - 如何比较AngularJS中ng-repeat中的值

转载 作者:行者123 更新时间:2023-11-28 18:13:16 25 4
gpt4 key购买 nike

我正在获取数据并使用 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}} 是否为 true 然后设置“Approved”如果 {{obj.IsActive}} 为 false,则设置值“Pending”。

最佳答案

像这样使用三元运算符很棘手

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

关于javascript - 如何比较AngularJS中ng-repeat中的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41182447/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com