0
我有一个AngularJS水疗中心,并希望从JSON中获取文件,目前效果很好。获取角js中嵌套的JSON对象
var app = angular.module("MyApp", []);
app.controller("TodoCtrl", function($scope, $http) {
$http.get('todos.json').
success(function(data, status, headers, config) {
$scope.posts = data;
}).
error(function(data, status, headers, config) {
alert("Error");
});
});
并绑定它重复一个列表。
<ul ng-repeat="post in posts">
<li>
<b>Name : </b> {{post.name}} <br>
<b>Adress/street :</b> {{post.address.street}}
</li>
</ul>
我的问题IST,如果我有嵌套的JSON内的另一个对象:
"adress": [
{
"street": "somewhat street",
"town": "somewhat town"
}]
我尝试post.adress.street
不起作用。有什么建议么?
您需要使用另一个NG重复的地址对象。请参阅[这里](http://stackoverflow.com/a/19840244/4067825)了解更多信息。 – Kailash 2014-09-30 10:42:32