So I am new to both AngularJS and CoffeeScript. I am trying out some simple examples and the one that I am trying to do is to display the count of number of checkboxes selected
and here is the Javascript for that
$scope.$watch('results', function(results){
$scope.count = 0;
angular.forEach(results, function(result){
if(result.selected){
$scope.count += 1;
}
})
}, true);
This works perfectly fine. Now I am trying to do the same thing in coffeescript and here is what I have
$scope.$watch 'results', (results) ->
$scope.count = 0;
( $scope.count += 1 if result.selected ) for result in $scope.results
There are no compilation errors in the above coffeescript but nothing happens when I select or deselect the checkboxes.
Any ideas?