Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ng hide和ng show工作不正常_Javascript_Jquery_Html_Angularjs - Fatal编程技术网

Javascript ng hide和ng show工作不正常

Javascript ng hide和ng show工作不正常,javascript,jquery,html,angularjs,Javascript,Jquery,Html,Angularjs,我想根据数据值隐藏和显示。我不知道我的代码出了什么问题。当我通过查看控制台日志来查找数据值时,它们会打印“[]” 我的控制器 $http.get('/bill/billByPatientId/'+patientData.id) .success(function (data, status, headers, config) { console.log(data); $scope.bills = data; }); 我的Html代码 ng隐藏: <

我想根据数据值隐藏和显示。我不知道我的代码出了什么问题。当我通过查看控制台日志来查找数据值时,它们会打印“[]”

我的控制器

$http.get('/bill/billByPatientId/'+patientData.id)
    .success(function (data, status, headers, config) {
        console.log(data);
        $scope.bills = data;
});
我的Html代码

ng隐藏:

<div class="row" data-ng-hide='bills'> 
        <div class="alert alert-info">
            <strong>No Bills!</strong> There is no history of bill for this
            patient
        </div>
</div>

没有账单此项没有bill的历史记录
病人
ng展会:

<div>
    <table data-ng-show='bills' class="table table-hover">
        <thead>
            <tr>
                <th class="col-lg-1 text-center">Bill No</th>
                <th class="col-lg-1 text-center">Date</th>
            </tr>
        </thead>
        <tbody class="scrollable">
            <tr data-ng-repeat="bill in bills">
                <td class="text-center">{{bill.billNo}}</td>
                <td class="text-center">{{bill.billDate | date:'dd-MM-yyyy'}}</td>
        </tbody>
    </table>
</div>

账单号
日期
{{bill.billNo}
{{bill.billDate}日期:'dd-MM-yyyy'}
我的问题是显示ng show内容。请帮忙。

这对我很有用

谢谢Nano

data-ng-show='bills.length > 0' 

data-ng-hide='bills.length > 0'


您是否尝试过
data ng show='bills.length>0'
?尝试
ng hide=“bills.length”
ng show=“!bills.length”
。空数组不会解除为false,length属性会解除为(当它为0时)来自服务器的数据为空。显示问题可能存在。您可以通过随机数据初始化账单进行检查。“数据ng show='bills.length>0'”。这很有效,谢谢@纳米技术
data-ng-show='bills[0]' 

data-ng-hide='bills[0]'