I found two other issues posted here experiencing a similar problem, but I'm fairly certain that my problem is not related to tags and instead an issue with the ng-repeat function in Angular.
I am using a loop to create the HTML string which can be used to fill all the table data.
So far, It is working as expected except for one detail. Each time my loop iterates the ng-repeat creates 3 empty rows before displaying the actual data.
Here's the controller.js
var ngApp = angular.module('ng-app', []);
ngApp.controller('repoCntrl', function($scope, $http) {
$scope.commitsData = function(){
$http.get('https://bitbucket.org/api/2.0/repositories/battlemidget/python-salesforce/commits')
.success(function(data){
$scope.commitArray = data;
});
}
$scope.commitsData();
});
And here's my index.html
<h3>Public activity in battlemidget's python-salesforce repository</h3>
<table id="mytable" border="1" class="table table-striped">
<tr>
<th>Commits</th>
<th>Comments</th>
<th>Parent<br>Branch(es)</th>
<th>Date</th>
<th>Username</th>
</tr>
<div id="tblContents"></div>
</table>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script>
var tbl=$("<table/>").attr("id","mytable");
var tString = "";
for (var i = 0; i <= 10; i++) {
tString += "<tr ng-repeat=\"commit in commitArray\">";
tString += "<td>{{commit["+i+"].hash.substr(0,6)}}</td>";
tString += "<td>{{commit["+i+"].message}}</td>";
tString += "<td>";
tString += "<p> {{commit["+i+"].parents[0].hash.substr(0,6)}}<br>"
+ "{{commit["+i+"].parents[1].hash.substr(0,6)}}</p>";
tString += "</td>";
tString += "<td>{{commit["+i+"].date.substr(0,10)}}</td>";
tString += "<td>{{commit["+i+"].author.raw}}</td>";
tString += "</tr>";
}
$("#mytable").append(tString);
</script>
I'm a newb to web development and this is my first serious project incorporating an API, using AngularJS, etc. Sorry I've I've done anything here that goes against standard conventions. Here's a picture showing the 3 empty rows that I believe ng-repeat is inserting. I would like to know what is causing this and how I can fix it. Thanks so much. (Hope this isn't too much code). Here's an image displaying the empty rows: https://i.sstatic.net/Atejf.png