如果没有数据将显示消息

if no data will be displayed message

本文关键字:消息 显示 数据 如果没有      更新时间:2023-09-26

我在 HTML 中有表,表的行是重复的 angular-js 指令,称为 ng-repeat。我正在搜索和排序具有 ng-model 指令的过滤器文本输入,以便我可以过滤任何数据。我在我的angularjs应用程序中使用ui-bootstrap。

一切正常,但如果用户搜索并且表中没有数据,那么我想使用 ng-show 指令显示消息。

这是我的代码。

                            <tbody>
                            <tr ng-repeat="item in HocaListesiDetails.slice(((currentPage-1)*itemsPerPage), (currentPage*itemsPerPage)) | filter:Search | orderBy:orderUserSelected " ng-style="item.TabloId == selectedHoca && {'background-color':'#ccc'}" ng-click="hocaSec(item.TabloId)">
                                <td>{{$index+1}}</td>
                                <td>{{item.AdSoyad}}</td>
                                <td>{{item.TcNumarasi}}</td>
                                <td>{{item.Telefon}}</td>
                                <td>{{item.DogumYeri}}</td>
                                <td>{{item.DogumTarihi | formattedFilter | date}}</td>
                            </tr>
                            <tr ng-show="FilteredHocaListesiDetails.length == 0" style="background:#fff;">
                                <td colspan="6">
                                    <div class="alert alert-info">
                                        <p class="text-center">Aradığınız kişi bulunamadı.</p>
                                    </div>
                                </td>
                            </tr>
                        </tbody>

试试这个

<tr ng-show="(FilteredHocaListesiDetails| filter:search).length == 0" style="background:#fff;">
                            <td colspan="6">
                                <div class="alert alert-info">
                                    <p class="text-center">Aradığınız kişi bulunamadı.</p>
                                </div>
                            </td>
                        </tr>

我认为,您需要在ng-show中包含"filter:Search"以检查长度。

No Results