我遇到了我的Angular Wine應用程序的問題。問題是我已經在單個控制器中使用了所有的東西,現在我想分割它們並且我已經完成了,但是我的數據不會顯示。所以我在尋找一些幫助。不顯示我的葡萄酒與服務
我得到我的所有對象,我應該和一切似乎都很好,除了數據沒有顯示。任何人都可以幫忙嗎?
的HTML:
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Year</th>
<th>Price</th>
<th> </th>
</tr>
</thead>
<tbody>
<tr ng-repeat="wine in wines">
<td><img ng-src="{{wine.Vineyard.ImageUrl}}" style="width: 100px; margin: 5px;" />{{wine.Name}}</td>
<td style="width: 250px;">{{wine.Description}}</td>
<td>{{wine.Vintage}}</td>
<td>{{wine.PriceRetail | currency}}</td>
<td>
<button ng-click="selectWine(wine)" class="btn btn-warning"><span class="glyphicon glyphicon-pencil"></span></button>
<button ng-click="removeWine(wine)" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span></button>
<button ng-click="favWine(wine)" class="btn btn-info"><span class="glyphicon glyphicon-star"></span></button>
<button ng-click="detailWine(wine)" class="btn btn-default"><span class="glyphicon glyphicon-zoom-in"></span></button>
</td>
</tr>
</tbody>
而且AngularJS從winedata文件
WineApp.controller("ListController", function($scope, $http, winedata) {
$scope.wines = winedata.getWines();
$scope.removeWine = function(wine) {
// console.log("remove wine");
var index = $scope.wines.indexOf(wine);
// console.log(index);
$scope.wines.splice(index, 1)
}
$scope.selectWine = function(wine) {
$scope.wine = wine;
}
$scope.updateWine = function(wine) {
// var editWine = {
// Name: $scope.wine.Name,
// Description: $scope.wine.Description,
// Vintage: $scope.wine.Vintage,
// PriceRetail: $scope.wine.PriceRetail
// }
$scope.wine = wine;
// console.log(wine);
// $scope.wines.extend(editWine);
alert("Updated!");
// $scope.wine.Name = "";
// $scope.wine.Description = "";
// $scope.wine.Vintage = "";
// $scope.wine.PriceRetail = "";
}
});
)它應該是從
WineApp.service('winedata', function($http) {
this.getWines = function() {
$http.get("http://services.wine.com/api/beta2/service.svc/json/catalog?apikey=2aef2f70e044ebcb683f46df93ac4eb9&size=100")
.success(function(response) {
// alert(response);
console.log(response.Products.List);
wines = response.Products.List;
})
}
this.searchForWine = function(Name) {
$http.get("http://services.wine.com/api/beta2/service.svc/json/catalog?apikey=2aef2f70e044ebcb683f46df93ac4eb9&size=100&search=" + Name)
.success(function(response) {
// alert(response);
console.log(response.Products.List);
wines = response.Products.List;
})
}
// wines.favoriteWine = [];
});
我應該說路由工作正常,它只是沒有顯示的數據 –