ng-hide和ng-show无法正常工作

时间:2015-04-09 07:50:52

标签: javascript jquery html angularjs

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

我的控制器

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

我的Html代码

纳克隐藏:

<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>

ng-show:

<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>

我的问题是显示ng-show内容。请帮忙。

1 个答案:

答案 0 :(得分:2)

这对我有用!

感谢Nano

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

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

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

data-ng-hide='bills[0]'
相关问题