Angular-js noob-ng-重复结果有时只是空白,可能是由于结果集的大小?

时间:2016-05-30 15:57:10

标签: javascript angularjs dirpagination

当我使用URL参数过滤结果时,将显示我的结果集。所以我想也许有太多结果被退回?

此页面: http://www.longrifle.com/forsale/forsaleitems.html#?categoryID=3&age=Contemporary

在这里使用Json输出: forsaleitems_mysql.php的categoryID = 3&安培;年龄=当代

这很好用,除非我在html页面上清空categoryID和age参数。没有这些参数的PHP工作正常,并返回适当的json但也许它的数据太多了? http://www.longrifle.com/forsale/forsaleitems.html中没有显示任何查询字符串。



<div class="bs-component" ng-app="myApp" ng-controller="forsaleitemsCtrl"> 
<table class="table table-striped table-hover">
	<thead>
	<tr>
        <th ng-click="sort('Title')">Title
        	<span class="glyphicon sort-icon" ng-show="sortKey=='Title'" ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
        </th>
		<th ng-click="sort('Price','currency')">Price
        	<span class="glyphicon sort-icon" ng-show="sortKey=='Price'" ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
        </th>
        <th>Pics</th>
        <!--<th>Age</th>-->
    </tr>
    </thead>
    <tbody>
	  <tr dir-paginate="x in items|orderBy:sortKey:reverse|filter:search|itemsPerPage:5">
	    <td><b>{{ x.Title }}</b><br><br>{{ x.Description }}<br><br>
	    	<a ng-click="showDetails = ! showDetails">Contact Information</a><br>
        <div ng-class="{ 'hidden': ! showDetails }">
	    		<span ng-hide="!x.Lastname">{{ x.Firstname }} {{ x.Lastname }}<br></span>
	    		<span ng-hide="!x.Company">{{ x.Company }}<br></span>	    		
	    		<span ng-hide="!x.Email"><a href="mailto:{{ x.Email }}">{{ x.Email }}</a><br></span>
	    		<span ng-hide="!x.PhoneNumber">{{ x.PhoneNumber }}<br></span>
	    		<span ng-hide="!x.Address1">{{ x.Address1 }}<br></span>
	    		<span ng-hide="!x.Address2">{{ x.Address2 }}<br></span>
	    		<span ng-hide="!x.City">{{ x.City }}, {{ x.State }} {{ x.Zip }}<br></span>
	    	</div>
	    </td>
	    <td>{{ x.Price | currency :'$' }}<span ng-if="x.ShippingDisplay > 0"> + shipping</span><br>
	    	<span ng-if="x.Sold > 0"><font color=red><b>SOLD</b></span>
	    </td>
	    <td>
	    <img ng-if="x.Pic1.length" class="image-zoom" id="{{ x.ID }}" src="/images/showcase/{{ x.Pic1 }}"><br><br>
	    <img ng-if="x.Pic2.length" class="image-zoom" id="img-{{ x.ID }}-2" src="/images/showcase/{{ x.Pic2 }}">
	    </td>
	  </tr>	
</tbody>
</table>

<dir-pagination-controls
       max-size="5"
       direction-links="true"
       boundary-links="true" >
</dir-pagination-controls>

</div>
</td>
          </tr>
                </tbody>
              </table></td>
          </tr>
</table>
<script>
var app = angular.module('myApp', ['angularUtils.directives.dirPagination']);
      
app.controller('forsaleitemsCtrl', function($scope, $http, $location) {
	$scope.categoryID = $location.search()['categoryID'];
	$scope.age = $location.search()['age'];
	if ($scope.categoryID==undefined){$scope.categoryID="";}
	if ($scope.age==undefined){$scope.age="";}
	var path='forsaleitems_mysql.php?categoryID='+$scope.categoryID+'&age='+$scope.age;    
    alert(path);
    $http.get(path)
    .then(function (response) {$scope.items = response.data.records;});
    
    $scope.sort = function(keyname, isCurrency){
    	$scope.predicate = keyname;
    	$scope.sortKey = keyname;   //set the sortKey to the param passed
    	$scope.reverse = !$scope.reverse; //if true make it false and vice versa
    	if(angular.isDefined(isCurrency)) {
            angular.forEach($scope.items, function (obj) {
            for(var i in obj )
            {
               if(i == keyname && obj[i] != '') 
                  obj[i] =  parseFloat(obj[i]);       
            }
           });
        }
    }
});

</script>
&#13;
&#13;
&#13;

0 个答案:

没有答案