I have a problem now regarding the ng-repeat in angularJS on how to assign value in $scope inside ng-repeat..
This is my scenorio:
I have a json file that content all the data. It shows like this..
[
{BookID:1,Chapter:1,ContentID:1,Content:"The quick brown fox is nice"},
{BookID:1,Chapter:1,ContentID:2,Content:"The quick brown fox is nice"},
{BookID:1,Chapter:1,ContentID:3,Content:"The quick brown fox is nice"},
{BookID:1,Chapter:1,ContentID:4,Content:"The quick brown fox is nice"},
{BookID:1,Chapter:2,ContentID:1,Content:"The quick brown fox is nice"},
{BookID:1,Chapter:2,ContentID:2,Content:"The quick brown fox is nice"},
{BookID:1,Chapter:2,ContentID:3,Content:"The quick brown fox is nice"},
{BookID:1,Chapter:2,ContentID:4,Content:"The quick brown fox is nice"},
{BookID:2,Chapter:1,ContentID:1,Content:"The quick brown fox is nice"},
{BookID:2,Chapter:1,ContentID:2,Content:"The quick brown fox is nice"},
{BookID:2,Chapter:1,ContentID:3,Content:"The quick brown fox is nice"},
{BookID:2,Chapter:1,ContentID:4,Content:"The quick brown fox is nice"}
]
Now that is my Example data..
When Book 1 is click, I want to Display it like this..
Book 1
Chapter 1
1 The quick brown fox is nice. 2 The quick brown fox is nice. 3 The quick brown fox is nice. 4 The quick brown fox is nice
Chapter 2
1 The quick brown fox is nice. 2 The quick brown fox is nice. 3 The quick brown fox is nice. 4 The quick brown fox is nice
This is my Code:
//Chapter is expected in every book so i just loop it depending on expected chapters (e.i, 1,2,3,4
<div data-ng-repeat="chap in Chapters">
<span style="font-size:20px">{{chap}}</span>
<span data-ng-repeat="testament in Testaments | filter:filters">
<b>{{testament.ContentID}}</b> {{testament.Content}}
</span>
<br />
</div>
In my Controller :
$scope.filters = function (row) {
var bookId = row.BookID.toString();
var chapter = row.Chapter.toString();
return ( bookId == $scope.bookId && chapter == $scope.currentChapter);
};
Now the Problem is that where i can get the $scope.currentChapter which must the value of chap
Please help me how assign value to $scope.currentChapter from the chap
Thank you so much..
contentinside thechapterand array thechapterinside abook.._(books).groupByMultiple(['BookID', 'Chapter', 'ContentID'])