簡體   English   中英

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

[英]ng-hide and ng-show not working Properly

我想根據數據值隱藏和顯示。 我不知道我的代碼有什么問題。 當我通過查看控制台日志來查找數據值時,它們會打印“ []”

我的控制器

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

我的HTML代碼

ng-hide:

<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內容。 請幫忙。

這對我有用!

謝謝納米

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

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

要么

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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM