Hier ist mein Code und ng-repeat generiert die Liste, zeigt aber nichts.ng-repeat zeigt nichts an
<!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>
Die json in der Konsole ist wie dieser
[{ "_id": "57a5877bb23cda352156315a", "userId": 257, "name": "Fortis", "E-Mail": "fortis @ Krankenhaus .com "," description ":" Fortis-Beschreibung zum Testen "," Adresse ": {" postalCode ":" 110088 "," state ":" DL "," Stadt ":" New Delhi "," streetAddress ":" s-fortis "}," koordinieren ": {" Koordinaten ": [77.1545846,28.7164134]," type ":" Punkt "}}]
Ihre Json-Array ist gleich wie console.log (response.data)? –