2014-01-14 48 views
-1

好吧,我有以下幾點:ng-click在ng-repeat中不會觸發?

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; 
}; 

HTML:

<select > 
<option ng-click="monthpickerclick()" class="animate-repeat" ng-repeat="returnpicker in monthpicker(singles)" value="{{returnpicker.date}}">{{returnpicker.date}}</option> 
</select> 

,輸出:

<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> 

這看起來不錯... 那麼,爲什麼monthpickerclick()不火的時候,我正在選擇一個選項? 克里斯

+1

您是否試過'