0
여기 내 코드와 ng-repeat가 목록을 생성했지만 아무것도 표시하지 않습니다. ng-repeat가 아무 것도 표시하지 않습니다.
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body ng-app="myApp">
<div ng-controller="getHospitalCtrl">
<h3>my list</h3>
<ul>
<li ng-repeat="hospital in hospitals track by $index">
<p class="name">{{hospital.name}}</p>
<p class="location">{{hospital.address.city}}</p>
</li>
</ul>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script>
var app = angular.module('myApp',[]);
app.controller('getHospitalCtrl',function($scope, $http){
console.log('i m in getHospitalCtrl');
$http.get("url")
.then(function(response){
$scope.hospitals = JSON.stringify(response.data.data);
console.log($scope.hospitals);
//this console is printing the right json here
});
});
</script>
</body>
</html>
콘솔의 JSON이
[{ "_id"처럼 "57a5877bb23cda352156315a", "userId를"257 "이름": "포티스", "이메일": "포티스 @ 병원 "주소": { "postalCode": "110088", "상태": "DL", "도시": "뉴 델리", "streetAddress": " S-포티스 "},"좌표 ": {"좌표 "[77.1545846,28.7164134,"유형 ":"포인트 "}}] 코드에서
하여 JSON 배열을 console.log (response.data)와 동일합니다 :
당신은 단지 하나의 초기화를해야합니까? –