sellingApp.factory('SellingService', ['$http', function ($http) {
return {
Status: Status
};
function Status() {
console.log(breeze);
return $http({
method: 'GET',
url: '/Services/Status',
params: {}
}).then(function (result) { return result.data; })
.catch(function (s) { console.log(s); });
}
}]);
sellingApp.factory("demoFac", ['$http', function ($http) {
var obj = {};
obj.fetchUserDetails = function () {
return $http.get('/Services/Status');
}
return obj;
}]);
我创建的两个控制器是为了实现这些“工厂”的每一个:我试图看看它们有何不同,哪个更好。 (似乎都不起作用 - 它们都返回“system.generic.list”而不是数据!!!
sellingApp.controller('sellingListCtrl', [
'$scope', '$location', 'breeze','Service',
function sellingListCtrl($scope, $location, breeze, Service) {
$scope.init = function () {
Service.Status().then(function (data) {
console.log(data);
});
}
$scope.init();
}
]);
sellingApp.controller('sellingListCtrl2', function ($scope, demoFac) {
demoFac.fetchUserDetails().success(function (response) {
$scope.lists = response;
});
});
答案 0 :(得分:0)
system.generic.list
不是Angular或JavaScript错误。最有可能来自你的后端/ api,这意味着你的控制器/工厂没有任何问题。
答案 1 :(得分:0)
您需要将C#列表序列化为JSON,以便角度可以处理它
你可以使用Newtonsoft.Json
return JsonConvert.SerializeObject(object)