데이터베이스에서 드롭 다운을로드하려고하는데 문제의 원인을 모르지만로드되지 않았거나 웹 서비스에서 반환 된 것을 볼 수 없습니다. 이다 WebAPI에서 데이터 가져 오기 및 AngularJs를 사용하여 드롭 다운에로드
나는 별도의 webapi 프로젝트를 생성하고 내 브라우저에서 직접 API를 메서드를 호출 할 때 그것은<ArrayOfGetCustomersList_Result xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Repository">
<GetCustomersList_Result>
<cust_name>Alex Fraser Group : Alex Fraser</cust_name>
<custid>Alex Fraser</custid>
<customer_auto>24</customer_auto>
</GetCustomersList_Result>
<GetCustomersList_Result>
<cust_name>BMA : BMA</cust_name>
<custid>BMA</custid>
<customer_auto>16</customer_auto>
</GetCustomersList_Result>
<GetCustomersList_Result>
<cust_name>DEMO CUSTOMER 1 : DEMO CUSTOMER 1</cust_name>
<custid>DEMO CUSTOMER 1</custid>
<customer_auto>1</customer_auto>
</GetCustomersList_Result>
<GetCustomersList_Result>
<cust_name>Hydraulink Toowoomba : Hydraulink Toowoomba</cust_name>
<custid>Hydraulink Toowoomba</custid>
<customer_auto>21</customer_auto>
</GetCustomersList_Result>
<GetCustomersList_Result>
<cust_name>QA Trackspares : QA Trackspares</cust_name>
<custid>QA Trackspares</custid>
<customer_auto>22</customer_auto>
</GetCustomersList_Result>
<GetCustomersList_Result>
<cust_name>Timms Contracting : Timms</cust_name>
<custid>Timms</custid>
<customer_auto>23</customer_auto>
</GetCustomersList_Result>
<GetCustomersList_Result>
<cust_name>UNKNOWN : UNKNOWN</cust_name>
<custid>UNKNOWN</custid>
<customer_auto>17</customer_auto>
</GetCustomersList_Result>
</ArrayOfGetCustomersList_Result>
내 각도 서비스 코드를 다음과 같이 JSON 형식의 데이터를 reutrn 않습니다
var app = angular.module('dashboardModule', ['oc.lazyLoad', 'directive.contextMenu'])
.service('dashboardService', ['$http', function ($http) {
this.loadCustomers = function (onSuccess, onError) {
onError = onError || function() { alert('Failure getting customers'); };
$http
.get('http://localhost:7999/api/dashboard/GetCustomersList')
.success(onSuccess)
.error(onError);
};
}]);
나는 나의 각도 컨트롤러에서이 전화 해요 :에
angular.module('dashboardModule')
.controller('dashboardController', ['$scope', '$rootScope', '$location', '$translate', 'dashboardService', function ($scope, $rootScope, $location, $translate, dashboardService) {
$scope.customers = [];
dashboardService.loadCustomers(customersLoaded,erroroccured);
function erroroccured(response)
{
alert(response.data);
}
function customersLoaded(response) {
$scope.customers=response.data;
}
$scope.selectedCustomer = $scope.customers[0].customer_auto;
}
]);
및 내 HTML 페이지로로드하려고 해요
<div class="col-sm-2"><select class="form-control" ng-model="selectedCustomer" ng-options="customer.customer_auto as (customer.custid+':'+customer.cust_name) for customer in customers">></select></div>
누군가가 코드의 문제점을 말해 줄 수 있습니까? 나는 IE 디버거에서이 오류가 발생 할
아약스에 문제가있을 경우 정의되지 않았거나 null 참조