Angularjs를 사용하여 웹 페이지에 JSON 응답을 표시하는 데 문제가 있습니다. DevTools에서 GET 요청이 훌륭하게 작동하고 모든 데이터를 가져올 수 있음을 알 수 있지만 목록에 표시 할 때는 점만 있습니다.
내 컨트롤러 :
budgetApp.controller('DepensesListCtrl', ['$scope', '$http',
function DepensesListCtrl($scope, $http) {
$scope.depenses = [];
$http.get('http://localhost:3000/api/depenses', {withCredentials: true}).success(function(data) {
$scope.depenses = data;
});
반복 사용 :
<div >
<div class="jumbotron text-center">
<h1>depenses Page</h1>
</div>
<ul ng-repeat="depense in depenses">
<li>{{depense.depname}}</li>
<li>{{depense.depcat}} </li>
</ul>
경고로 디버깅을 시도했지만 depenses 배열이 항상 정의되지 않은 것으로 나타났습니다.
데이터는 Depense
반복하려는 배열을 포함 하는 속성이있는 개체입니다.
시험:
$http.get('http://localhost:3000/api/depenses', {withCredentials: true}).success(function(data) {
$scope.depenses = data.Depense;
// ^^^ property that contains array
});
또는:
<ul ng-repeat="depense in depenses.Depense">
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다