एनजी-दोहराने वाले सरणी को कोणीय - कोणीय में दोहराएं

मुझे नेस्टेड सरणी को आउटपुट करने में समस्याएं हैंमेरी 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>

ऐसा इसलिए है क्योंकि पहला एनजी-दोहराव प्रत्येक आइटम को $ scope.books बनाता है जो एक पुस्तक उदाहरण बनाता है। तब आपके पास एक है नेस्टेड पुनरावर्तक करें कि पुनरावर्तक को मूल उदाहरणों से मूल उदाहरण का उपयोग करना होगा। इस मामले में कौन सा है book.

इस छद्म कोड पर विचार करें:

each item in array
each subitem in item

प्रारंभ में आपने यह छद्म कोड बनाया था:

each item in array
each subitem in array.item

जो जब आप इसे लिखते हैं तो यह स्पष्ट करता है कि आप क्या त्रुटि चाहते थे।