Hello Luke, Sander
Thanks for the reply.
I'm not using the $index.
Some simplified code:
I have a table created by ngRepeat:
<table class="table table-striped">
<thead>
<th>
<div class="floating" resource-checkbox-all></div>
</th>
<th>Name</th>
<th>Description</th>
<th>Date </th>
</thead>
<tr ng-repeat="resource in resourceData.data">
<td style="padding-right: 5px; vertical-align: middle"><div resource-checkbox="{{resource}}"></div></td>
<td style="padding-right: 5px">{{resource.fullname}}</td>
<td style="padding-right: 5px">{{resource.description}}</td>
<td style="padding-right: 5px">{{resource.dateResource | javaTimeToGmailStyle }}</td>
</tr>
</table>
The resource-checkbox code looks like this:
portalModule.directive('resourceCheckbox', ['$rootScope', function ($rootScope) {
var ResourceCheckboxController = function ($scope, ResourceService) {
$scope.isChecked = false;
$scope.internalResource;
$scope.checkResource = function($event){
$event.stopPropagation();
$scope.isChecked = !$scope.isChecked;
}
var readSelectedItems = $rootScope.$on("readSelectedItems", function (){
if($scope.isChecked){
}
});
var unreadSelectedItems = $rootScope.$on("unreadSelectedItems", function (){
if($scope.isChecked){
}
});
}
return {
restrict: 'A',
template: '<input type="checkbox" ng-checked="isChecked" ng-click="checkResource($event)"></input>',
controller: ResourceCheckboxController,
link: function(scope, element, attrs){
scope.internalResource = JSON.parse(attrs.resourceCheckbox);
}
}
}]);
When I check one of the checkboxes on the first page and then navigate to page two resourceData.data in the ngRepeat segments update's and draws the new view. All the resourceCheckboxes on page one get the destroy event. But when readSelectedItems is broadcasted the checkbox is selected on page one still seems to be responding to the broadcast and marks the line i checked on page one as read.
I'm probably doing overlooking something silly, or maybe i'm not approaching this the right way. All help is welcome.
Thanks in advance.