JSON 응답에서 항목을 반환하려고하는데 구문을 파악할 수 없습니다. I이 방법 getAll()
와 AngularJS와 서비스가
{"Items":[{"Id":"ABC1234","Name":"Tests-TestItem01","Desc":"Test Item 01"}]}
:
function getAll() {
return $http.get('http://servername.com/TestItems/GetAll')
.then(getAllComplete)
.catch(function(message) {
exception.catcher('XHR Failed for Applications')(message);
$location.url('/');
});
function getAllComplete(data, status, headers, config) {
//return data.data[0].data.results;
logger.info(data[0]);
return data[0];
}
}
및 I는 제어기가 응답은 사용자 ServiceStack DTO는 (내부 배열 소위 "항목"통지) 인 이 서비스를 사용하려고 시도하는 것은 :
(function() {
'use strict';
angular
.module('testmodule')
.controller('TestModule', TestModule);
function TestModule(testItemSvc, logger) {
var vm = this;
vm.testItems = [];
vm.title = "Test Items";
vm.activate = activate;
activate();
function activate()
{
return getTestItems().then(function(){
// Log and announce
logger.info('Test Items loaded');
});
}
function getTestItems(){
return testItemSvc.getAll().then(function(data){
vm.testItems = data;
return vm.testItems;
});
}
}
})();
난하지만 난 항목을 반환하는 방법을 확인할 수 없습니다 (필자는 JSON 얻은 곳이다) 응답이 돌아 오는 것을 볼 수 있습니다. 그게 어처구니없는 부분이 모두 getAllComplete()
인 곳입니다.
편집 :
가 나는
activate()
기능과 약속이 성공적으로 작성되었을 때 보여줄 수있는 toastr 팝업을 추가했다. 그것은
입니다. 화재. 그리고 내보기 HTML 안에는
vm.title
에 바인딩되어 있습니다. 그러나 을 통해 루프하려면
ng-repeat
을 사용하고 있으며 아무 것도 표시하지 않습니다.
왜 서비스에 컨트롤러를 삽입하지 않습니까? – underscore