Angularjs 如果未找到用于搜索的记录,则显示消息,anjularJS表

Angularjs 如果未找到用于搜索的记录,则显示消息,anjularJS表,angularjs,Angularjs,如果搜索结果为“未找到记录”,我想显示一条消息 <table class="table table-bordered table-striped" id="tbl1"> <tbody ng-repeat="d in newData | filter:searchText"> <tr ng-repeat="m in d.category "> <th id="heading" ng-b

如果搜索结果为“未找到记录”,我想显示一条消息

<table class="table table-bordered table-striped" id="tbl1">
        <tbody ng-repeat="d in newData | filter:searchText">
            <tr ng-repeat="m in d.category ">
                <th id="heading" ng-bind="m.name"></th>
            </tr>
            <tr>
                <th></th>
                <th id="proname" ng-repeat="p in d.procedure" ng-bind="p.procedures.name" repeat-end="onEnd($index)"></th>
            </tr>
            <tr ng-repeat="(index, hos) in myHospital | filter:searchHospital" id="hideRow">
                <td id="hsname">{{hos.name}}</td>
                <td id="price" class="edit" ng-repeat="pro in d.procedure" ng-bind-html="valueCheck(d._id,pro._id,hos._id)"></td>
                <td id="enq" class="edit">Enquire Now</td>
            </tr>
            <tr ng-show="([d] | filter:searchText).length == 0"><td>No Result Found</td></tr>
        </tbody>
    </table> 

{{hos.name}
现在查询
没有找到结果

这是我的表的演示,我尝试了类似于
ng if(object.length==0)
的方法,但它对我不起作用。请提供一些建议

您可以尝试使用
ng repeat=“d in fData=(newData | filter:searchText)”
然后使用
ng show=“fData.length==0”
,如下所示

我将No Records
移到了
的正下方,因为它应该在
ng repeat
之外。你可以随意改变。单击下面的运行代码段以检查此工作

//代码在这里
var app=angular.module('pnqApp',['ngSanitize']);
app.controller('procedureController',函数($scope,$http){
$scope.valueCheck=函数(v1、v2、v3){
var keepGoing1=true;
var keepGoing2=true;
var keepGoing3=真;
$scope.res=未定义;
angular.forEach($scope.newData,函数(项){
如果(继续){
如果(项目id==v1){
$scope.arr1=项目;
keepGoing1=false;
角度.forEach($scope.arr1.procedure,function(项目){
如果(保持2){
如果(项目id==v2){
$scope.arr2=项目;
keepGoing2=false;
//console.log('apple',项);
角度。forEach($scope.arr2.hospital,功能(项目){
如果(保持3){
如果(item.hospitalId==v3){
keepGoing3=false;
$scope.res=item.amountendoller;
//log('orange',$scope.res);
}
}
});
}
}
});
}
}
});
如果($scope.res!=未定义),则返回$scope.res;
否则返回'NULL';
}
//突出TD背景色的逻辑
$(文档).ready(函数(){
$('.edit')。每个(函数(){
$(this.find('b').css('background-color','red');
});
});
//获取医院详细信息的api
$scope.myHospital=[
{
“_id”:“57aafcce5cf10e3c0faf9e04”,
“名称”:“会议医院”
},
{
“_id”:“57ac1ef1d1942e6979ce7dce”,
“名称”:“试验医院”
},
{
“_id”:“57ac64615f280eea7e2f227b”,
“名称”:“我的新医院”
}
]
$scope.newData=[
{
“_id”:“57e61f768c37a870698f3273”,
“程序”:[
{
“_id”:“57ecc1917c3c54a049545cc0”,
“医院”:[
{
“_id”:“580b2b2b333272f801b0c30e”,
“程序ID”:“57ecc1917c3c54a049545cc0”,
“amountinINR”:1347,
“amountinDoller”:“110”,
“医院ID”:“57aafcce5cf10e3c0faf9e04”,
“类别ID”:“57e61f768c37a870698f3273”,
“_v”:0
},
{
“_id”:“580b3a37333272f801b0c314”,
“程序ID”:“57ecc1917c3c54a049545cc0”,
“amountinINR”:5764,
“amountinDoller”:643,
“hospitalId”:“57ac1ef1d1942e6979ce7dce”,
“类别ID”:“57e61f768c37a870698f3273”,
“_v”:0
},
{
“_id”:“580f3b08333272f801b0c319”,
“程序ID”:“57ecc1917c3c54a049545cc0”,
“amountinINR”:954,
“amountinDoller”:“2467”,
“hospitalId”:“57ac64615f280eea7e2f227b”,
“类别ID”:“57e61f768c37a870698f3273”,
“_v”:0
}
],
“程序”:{
“_id”:“57ecc1917c3c54a049545cc0”,
“名称”:“测试twe”,
“类别ID”:“57e61f768c37a870698f3273”,
“createdAt”:“2016-09-29T07:24:01.218Z”,
“_v”:0
}
},
{
“_id”:“57e8f944aaf4b58718ae2862”,
“医院”:[
{
“_id”:“580b2a5d333272f801b0c304”,
“程序ID”:“57e8f944aaf4b58718ae2862”,
“amountinINR”:1102,
“amountinDoller”:11025,
“hospitalId”:“57ac1ef1d1942e6979ce7dce”,
“类别ID”:“57e61f768c37a870698f3273”,
“_v”:0
},
{
“_id”:“580b2b26333272f801b0c30d”,
“程序ID”:“57e8f944aaf4b58718ae2862”,
“amountinINR”:422,
“amountinDoller”:4632,
“医院ID”:“57aafcce5cf10e3c0faf9e04”,
“类别ID”:“57e61f768c37a870698f3273”,
“_v”:0
}
],
“程序”:{
“_id”:“57e8f944aaf4b58718ae2862”,
“n