我新的角度,我想列出我的數據在數據庫中。但是,我剛開沒有定義error..This $範圍是我的代碼
productsService
.getProducts()
.success(function (data, status, headers, config) {
$scope.products = data;
console.log($scope.products);
})
.error(function (error) {
//Showing error message
$scope.status = 'Unable to retrieve product' + error.message;
});
在我產品服務我有
return {
getProducts: function() {
return $http({
method: 'GET',
url: '/api/Products'
}).success(function (data) {
alert("success");
// console.log(data);
}).error(function (error) {
//Showing error message
alert("failed");
$scope.status = 'Unable to retrieve products' + error.message;
console.log($scope.status);
});
},
我剛剛收到失敗警報。請幫助!!!在後端我能夠從數據庫中獲取數據。
我試圖直接訪問API /產品,我得到了一些錯誤,我沒有任何錯誤>的線索出現錯誤。 'ObjectContent'1'類型無法序列化內容類型爲'application/xml;字符集= UTF-8' 。 ExceptionMessage> System.InvalidOperationException ExceptionType> –
Philomath
2014-10-17 07:43:34