I am getting some data with http and updating the $scope.comments
variable.Then I display it with ng-repeat however variable is updating correctly but ng-repeat is not working. Here is javascript:
$scope.updateComments = function(taskId){
var contentInput = document.getElementById(taskId);
contentInput.value = '';
$http.get('/loadTask/'+taskId).success(function(task){
angular.forEach(task.comments,function(comment){
$http.get('/loadComment/'+comment).success(function(c){
$scope.comments[comment] = c;
console.log('Comments now',$scope.comments);
});
});
});
}
I can't use $scope.$apply
because it's already being called by $http
request.
This is html:
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12">
{{comments}}
<div class="comments" ng-repeat="comment in task.comments track by $index">
<p><a href="{{comments[comment].author}}">
{{comments[comment].author}}
</a>{{comments[comment].content}}</p>
</div>
</div>
</div>
Also {{comments}}
is updating correctly.
Can anyone help me, thanks in advance!
ng-repeat="comment in task.comments track by $index"