I currently have the code snippet below:
scope.monthpickerclick = function(scope){
$window.alert('test');
console.log(scope);
};
scope.monthpicker = function(alldatesdumparray){
var alldatesdump = booking.getalldates();
var alldatesdumparray = $.map(booking.getalldates(), function(value, index) {
var dropdates = new Date(value.date);
var dropdate = dropdates.getDate();
var month=new Array();
month[0]="January";
month[1]="February";
month[2]="March";
month[3]="April";
month[4]="May";
month[5]="June";
month[6]="July";
month[7]="August";
month[8]="September";
month[9]="October";
month[10]="November";
month[11]="December";
var dropmonth = month[dropdates.getMonth()];
var checkmonth = dropdates.getMonth();
var dropyear = dropdates.getFullYear();
var joindates = dropmonth + '-' + dropyear;
var monthyear = checkmonth + '- '
var today = new Date();
var mm = today.getMonth(); //January is 0!
var yyyy = today.getFullYear();
if(mm < checkmonth && dropyear < yyyy){
}else{
value.date = joindates;
value.month = checkmonth;
value.Year = dropyear;
return [value];
}
});
//console.log(alldatesdumparray);
var dupes = {};
var singles = [];
$.each(alldatesdumparray, function(i, el) {
if (!dupes[el.date]) {
dupes[el.date] = true;
singles.push(el);
return singles;
}
});
return singles;
};
Associated HTML code:
<select >
<option ng-click="monthpickerclick()" class="animate-repeat" ng-repeat="returnpicker in monthpicker(singles)" value="{{returnpicker.date}}">{{returnpicker.date}}</option>
</select>
This will output the following:
<select>
<!-- ngRepeat: returnpicker in monthpicker(singles) -->
<option ng-click="monthpickerclick()" class="animate-repeat ng-scope ng-binding" ng-repeat="returnpicker in monthpicker(singles)" value="January-2014">January-2014</option>
<option ng-click="monthpickerclick()" class="animate-repeat ng-scope ng-binding" ng-repeat="returnpicker in monthpicker(singles)" value="February-2014">February-2014</option>
<option ng-click="monthpickerclick()" class="animate-repeat ng-scope ng-binding" ng-repeat="returnpicker in monthpicker(singles)" value="March-2014">March-2014</option>
<option ng-click="monthpickerclick()" class="animate-repeat ng-scope ng-binding" ng-repeat="returnpicker in monthpicker(singles)" value="April-2014">April-2014</option>
<option ng-click="monthpickerclick()" class="animate-repeat ng-scope ng-binding" ng-repeat="returnpicker in monthpicker(singles)" value="May-2014">May-2014</option>
<option ng-click="monthpickerclick()" class="animate-repeat ng-scope ng-binding" ng-repeat="returnpicker in monthpicker(singles)" value="June-2014">June-2014</option>
<option ng-click="monthpickerclick()" class="animate-repeat ng-scope ng-binding" ng-repeat="returnpicker in monthpicker(singles)" value="July-2014">July-2014</option>
<option ng-click="monthpickerclick()" class="animate-repeat ng-scope ng-binding" ng-repeat="returnpicker in monthpicker(singles)" value="August-2014">August-2014</option>
<option ng-click="monthpickerclick()" class="animate-repeat ng-scope ng-binding" ng-repeat="returnpicker in monthpicker(singles)" value="September-2014">September-2014</option>
<option ng-click="monthpickerclick()" class="animate-repeat ng-scope ng-binding" ng-repeat="returnpicker in monthpicker(singles)" value="October-2014">October-2014</option>
<option ng-click="monthpickerclick()" class="animate-repeat ng-scope ng-binding" ng-repeat="returnpicker in monthpicker(singles)" value="November-2014">November-2014</option>
<option ng-click="monthpickerclick()" class="animate-repeat ng-scope ng-binding" ng-repeat="returnpicker in monthpicker(singles)" value="December-2014">December-2014</option>
</select>
Despite the appearance that everything should be working fine, the issue remains of why does monthpickerclick() not execute when selecting an option? Chris