我是Angular的新手,我尝试使用ng-repeat更新我的表格。但它不起作用。
这是我的代码:
$scope.customers = function(){
$http({
method: "GET",
url: $rootScope.webApiUrl+"/customers/"+$rootScope.session,
dataType: "json"
}).then(function requestSuccess(response){
$scope.customerData = response.data;
console.log($scope.customerData);
$scope.customerDataReady = true;
}, function requestError(response){
if(response.status == 404)
{
}
else if(response.status == 500)
{
alert("Database Error");
}
});
}
$scope.saveNewCustomer = function(){
[...]
$scope.customers();
}
<div ng-controller="customerCtrl" ng-init="customers()">
<!--- Space for Javascript --->
<script src="module/customer/js/customer.js"></script>
<!--- Javascript End --->
<!--- Space for Modals --->
<div ng-include="'module/customer/html/customerDetails.html'"></div>
<div ng-include="'module/customer/html/customerAddressNew.html'"></div>
<div ng-include="'module/customer/html/customerNew.html'"></div>
<!--- Modals End -->
<h2>Customers</h2>
<hr>
<button class="btn" data-toggle="modal" data-target="#customerNew"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> New Customer</button>
<hr>
<p>List of all Customers</p>
<br />
<input type="text" ng-model="searchCustomer" class="form-control" placeholder="Search Customer">
<br />
<div>
<div ng-if="customerDataReady">
<table class="table table-striped table-responsive table-list">
<tr>
<th>ID</th>
<th>Name</th>
<th>Address</th>
<th>Zip</th>
<th>City</th>
<th>Country</th>
<th>Phone</th>
<th>Mail</th>
</tr>
<tr ng-repeat="customer in customerData | filter:searchCustomer" ng-click="customerDetails(customer.customerid)">
<td>{{customer.customerid}}</td>
<td>{{customer.name}}</td>
<td>{{customer.address}}</td>
<td>{{customer.zip}}</td>
<td>{{customer.city}}</td>
<td>{{customer.country}}</td>
<td>{{customer.phone}}</td>
<td>{{customer.mail}}</td>
</tr>
</table>
</div>
</div>
</div>
我看到,scope.customerData正确更新,但Table没有!
你有什么想法如何实现这个目标?