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