Is there a way to calculate the number of a specific day of the week occurring in a month using AngularJS? For example, how can I determine the count of Saturdays in a given month? Thank you. Here is the code snippet I have been working on:
<!doctype html>
<html ng-app="myApp">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script>
</head>
<body>
<div ng-app="myApp" ng-controller="myCtrl" ng-init="getdates()">
<p ng-if="x='Sat'">{{dates.length}}</p>
<div ng-repeat="x in dates">
<input type="checkbox" ><p ng-show="x">{{x | format:'ddd'}}</p></input>
</div>
</div>
<script>
angular.module('myApp', [])
.controller('myCtrl', function($scope) {
$scope.dates=[];
$scope.getdates=function(){
for(i=0;i<31;i++){
$scope.myDate = i+' Feb 2015 00:00:00 GMT';
$scope.dates.push($scope.myDate)
}
};
})
.filter('format', function() {
return function(input, format) {
return moment(new Date(input)).format(format);
};
})
;
</script>
</body>
</html>