When working with an $http.post() call and trying to update an HTML table in the success() callback, I encountered an issue:
.success(function (data) {
$scope.categories.push(data);
});
Here is the HTML code for the table:
<tbody>
<tr ng-repeat="category in categories">
<td>{{category.Id}}</td>
<td>{{category.CategoryTypeID}}</td>
<td>{{category.IsContentLibraryItem}}</td>
<td>{{category.Title}}</td>
<td>{{category.CreatedBy}}</td>
<td>{{category.CreatedDate}}</td>
</tr>
</tbody>
The problem arises when an empty row appears at the bottom of the table. It seems that the success() function is executing before the post() function completes its task. This leads to incomplete data being pushed, resulting in an empty row in the table.
To resolve this issue, I need a way to delay the $scope.categories.push(data);
line until after the post() call is fully complete. In other libraries like jQuery/Ajax, there was an onComplete() event that served a similar purpose. Is there an equivalent in AngularJS?