I have a problem trying to watch in my controller a collection generated by a filter in the view.
I store the filtered data in a variable :
<table class="table">
<tr ng-repeat="item in filteredCollection = (myCollection | filter: txtSearch)">
<td ng-bind="item"></td>
</tr>
</table>
and I would like to subscribe to changes of 'filteredCollection ' in my controller :
$scope.$watchCollection('filteredCollection', function() {
if (typeof($scope.filteredCollection) != 'undefined')
console.log('Results changed : ' + $scope.filteredCollection.length);
});
I have set up this JSFiddle to show you my issue : my watch function is never called.
Fun Fact, it works when I remove all the <tabset> <tab> tags in my HTML. I think I messed up with the $scope, but I don't get why. Maybe the tabset create a new $scope child or something.
I hope you guys will find out what is going on here,
Cheers