Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.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 如果表格有行,则以angularjs显示表格_Javascript_Angularjs_Sql Server_Fetch - Fatal编程技术网

Javascript 如果表格有行,则以angularjs显示表格

Javascript 如果表格有行,则以angularjs显示表格,javascript,angularjs,sql-server,fetch,Javascript,Angularjs,Sql Server,Fetch,我正在mvc5 angularjs中创建一个基于web的应用程序,其中有一个表 <div class="table-responsive scroll" ng-hide="hidetable"> <table id="table" class="table table-bordered table-condensed"> <thead> <tr class="bg-primary">

我正在mvc5 angularjs中创建一个基于web的应用程序,其中有一个表

<div class="table-responsive scroll" ng-hide="hidetable">
    <table id="table" class="table table-bordered table-condensed">
         <thead>
              <tr class="bg-primary">
                  <th><a href="#" class="erp-tb-a" ng-click="order('date')">Date</a></th>
                  <th><a href="#" class="erp-tb-a" ng-click="order('day')">Day</a></th>
                  <th><a href="#" class="erp-tb-a" ng-click="order('brandname')">BrandName</a></th>
                  <th><a href="#" class="erp-tb-a" ng-click="order('zone')">Zone</a></th>
                  <th><a href="#" class="erp-tb-a" ng-click="order('location')">Location</a></th>
                  <th><a href="#" class="erp-tb-a" ng-click="order('area')">Area</a></th>
                  <th><a href="#" class="erp-tb-a" ng-click="order('trainer')">TrainerName</a></th>
                  <th><a href="#" class="erp-tb-a" ng-click="order('program')">Program</a></th>
                  <th><a href="#" class="erp-tb-a" ng-click="order('trainingno')">Training Id</a></th>
                  <th><a href="#" class="erp-tb-a" ng-click="order('amount')">Amount</a></th>
                  <th><a href="#" class="erp-tb-a">Remark</a></th>
                  <th><a href="#" class="erp-tb-a" ng-click="order('sonvinid')">SonvinId</a></th>
                  <th><a href="#" class="erp-tb-a" ></a>Add</th>
              </tr>
              <tr class="bg-primary">
                  <td><input type="text" class="erp-input" ng-model="search.date" /></td>
                  <td><input type="text" class="erp-input" ng-model="search.day" /></td>
                  <td><input type="text" class="erp-input" ng-model="search.brandname" /></td>
                   <td><input type="text" class="erp-input" ng-model="search.zone" /></td>
                   <td><input type="text" class="erp-input" ng-model="search.location" /></td>
                   <td><input type="text" class="erp-input" ng-model="search.area" /></td>
                   <td><input type="text" class="erp-input" ng-model="search.trainer" /></td>
                   <td><input type="text" class="erp-input" ng-model="search.program" /></td>
                   <td><input type="text" class="erp-input" ng-model="search.trainingno" /></td>
                   <td><input type="text" class="erp-input" ng-model="search.amount" /></td>
                   <td><input type="text" class="erp-input" /></td>
                   <td><input type="text" class="erp-input" ng-model="search.sonvinid" /></td>
                   <td></td>
              </tr>
          </thead>
          <tbody>
              <tr ng-repeat="p in getallcompany | orderBy:predicate:reverse | filter:search">
                  <td>{{p.date}}</td>
                  <td>{{p.day}}</td>
                  <td>{{p.brandname}}</td>
                  <td>{{p.zone}}</td>
                  <td>{{p.location}}</td>
                  <td>{{p.area}}</td>
                  <td>{{p.trainer}}</td>
                  <td>{{p.program}}</td>
                  <td>{{p.trainingno}}</td>
                  <td>{{p.amount}}</td>
                  <td><input type="text" class="erp-input" style="width:90%; border:1px solid black;" ng-model="mdremarks" /></td>
                  <td>{{p.sonvinid}}</td>
                  <td><md-checkbox tabindex="0" area-label="none" role="checkbox" ng-click="clickcheckbox()"></md-checkbox></td>
               </tr>
           </tbody>
  </table>
  <div style="margin-bottom:20px">
       <a href="#" style="cursor:pointer;" class="btn btn-primary active">Generate Bill</a>
       <a href="#" style="cursor:pointer;" class="btn btn-warning active">Back</a>
   </div>


</div>
现在我想要的是,如果表是空的(即,如果从sql返回的值没有行,那么表应该隐藏,如果返回的值有行,那么表应该显示

var app = angular.module('myapp', ['ngMaterial']);
app.controller('mycontroller', function ($scope, $http) {
            $scope.hidetable = true;
这是我的控制器,表格将在页面加载时隐藏

$http.get('/freezeservice.asmx/gettabledetails', {
                params: {
                    log: log,
                    pm: pm,
                    comname: $scope.mdcompany,
                    mm: $scope.datemm,
                    yy: $scope.dateyy
                }
            })
                .then(function (response) {
                    {
                        $scope.getallcompany = response.data.info;

                    }
                });
这就是我获取数据的方式


需要您的帮助

只要在条件下添加
ng即可。您可以使用
ng show
ng hide

<table ng-if="getallcompany.length">

如果出现条件,只需添加
ng即可。您可以使用
ng show
ng hide

<table ng-if="getallcompany.length">


它不应该是像ng if=“getallcompany.length>0”这样的布尔表达式吗?它不应该是像ng if=“getallcompany.length>0”这样的布尔表达式吗?