I have a custom directive (which generates a table) that repeats twice on my index page. Table values are populated with the $ scope.globalrows variable. Despite the fact that globalrows contains 2 array values, it always prints the second value. How to modify my template or directives to show values unique to this table and prevent overwriting the contents.
Question: Tables are repeated twice with the second contents of the table in globalarray. I see the second table overwrites the first table.
index.html
<grid-print section="1"></grid-print>
<grid-print section="2"></grid-print>
template: print.dir.html
<form class="form-horizontal clearfix">
<table class="grid table table-bordered">
<thead>
<tr>
<th ng-repeat="col in cols">{{col.title}}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in globalrows track by $index" index={{index}}>
<td ng-repeat="col in cols">
<span>{{ row[col.field] }}</span>
</td>
</tr>
</tbody>
</table>
</form>
directive:
.directive("gridPrint", function($sessionStorage, dataservice) {
return {
restrict: 'E',
templateUrl: "components/print/templates/print.dir.html",
replace: true,
controller: function($scope, $state, $attrs) {
$scope.globalrows = dataservice.getCollectionData();
},
link: function(scope, element, attributes){
}
};
})
Another directive that generates strings is cols:
.directive("grid", function() {
return {
restrict: 'E',
templateUrl: "components/section/directives/section.shared.dir.html",
replace: true,
controller: function($scope) {
$scope.$on('ready-to-render', function(e, rows, cols) {
$scope.globalrows.rows = rows;
$scope.cols = cols;
});
}
};
})
globalrows array
