/ / ng-repeat вложени масиви в ъглови - angularjs

ng-repeat вложен масив в ъглови ъгли

Имам проблеми с извеждането на вложените масиви вмоят app.js файл. Мога да получа външния масив към изхода, но рецензиите за книгата не се визуализират на екрана. Ето какво имам досега.

app.js

var app = angular.module("DirectivesTest", []);
app.directive("bookReviews", function(){
return {
restrict: "E",
templateUrl: "book-reviews.html",
controller: "BookController"
//controller function
}; //end return
}) //end directive



app.controller("BookController",  function($scope){
$scope.books = [{


title: "Harry Potter and the Sorcerer"s Stone",
description: "Harry Potter has no idea how famoushe  is. That"s because he"s being raised by his miserable aunt and uncle who are terrified Harry will learn that he"s really a wizard, just as his parents were. But everything changes when Harry is summoned to attend an infamous school for wizards, and he begins to discover some clues about his illustrious birthright. From the surprising way he is greeted by a lovable giant, to the unique curriculum and colorful faculty at his unusual school, Harry finds himself drawn deep inside a mystical world he never knew existed and closer to his own noble destiny.",

review: [{


stars: 5,
body: "I love this book!",
author: "JoeJohnson@gmail.com",
createdOn: 42434343

},
{

stars: 4,
body: "It was pretty good. A little long though",
author: "PaulPaulson@gmail.com",
createdOn: 42434343
},
{
stars: 5,
body: "It"s the best book I"ve ever read.",
author: "JimJohnson@gmail.com",
createdOn: 454535543

}
]
}];

})

index.html

<!DOCTYPE html>
<html ng-app="DirectivesTest">
<head>
<title>Directives Practice</title>
<link rel="stylesheet" href="app.css">
<script src="bower_components/angular/angular.js"></script>
<script src="app.js"></script>
</head>
<body>
<div id="header">
The #1 Book Review Site With Only 6 Books!
</div>
<div class="container">
<div class="row">
<div class="col-md-4">
<div ng-controller="BookController">
<div class="test" ng-repeat="book in books">
{{book.title}}
<div ng-repeat="bookReview in books.review">
{{bookReview.review}}
</div> <!--End parent ng-repeat-->

</div>
</div>



</div>

</div>
<book-reviews></book-reviews>
</body>
</html>

Отговори:

1 за отговор № 1

трябва да бъде

<div ng-repeat="bookReview in book.review"> не

<div ng-repeat="bookReview in books.review">


0 за отговор № 2
<div ng-controller="BookController">
<div class="test" ng-repeat="book in books">
{{ book.title }}
<div ng-repeat="review in book.review">
{{ review.body }}
</div>
</div>
</div>

Това се дължи на факта, че първото ng-repeat отнема всяка форма от $ scope.books, която създава потребителски пример. Тогава имате вложен ретранслаторът, който повторителят трябва да използва изходния екземпляр от оригиналния масив от елементи. Което в този случай е book.

Помислете за този псевдокод:

each item in array
each subitem in item

Първоначално сте създали този псевдокод:

each item in array
each subitem in array.item

което, когато го напишете, го прави очевидно, какво е грешката ви.