I want to bind "Thread" and "Comments".
- Thread 1
- Comment 1
- Comment 2
- Comment 3
- Thread 2
- Comment 1
- Comment 2
- Thread 3
- Comment 1
- Comment 2
- Comment 3
- Comment 4
- Comment 5
I have to fetch "Thread" and "Comment" from database by service. Thread Service gives data of all Threads while "Comment" service takes Thread ID and returns only passed Thread ID Comment.
So, How to bind the data like above nested list by tow separate services.
app.controller('ThreadCtrl', function ($scope, $http, $location) {
$scope.Threads = [];
$scope.Comments = [];
$http({
method: 'POST',
url: 'api/ThreadList'
}).success(function (data) {
$scope.Threads = JSON.parse(data);
});
$http({
method: 'POST',
url: 'api/CommentList',
data: JSON.stringify({ ThreadID: 0 }) //The problem is, ThreadID will resolve at runtime
}).success(function (data) {
$scope.Threads = JSON.parse(data);
});
})