在angular-bootstrap-datetimepicker中禁用将来的日期

时间:2015-11-16 10:27:32

标签: javascript angularjs datetimepicker bootstrap-datetimepicker

我无法停用将来的日期。

使用angular-bootstrap-datetimepicker

DateObject()

尝试在指令before-render内添加selectable=false;但没有成功......

修改

发现我可以使用function kitemoving() { setInterval(function(){ kite.animate({ top: '+=30' },{ duration: 1500 }); kite.animate({ top: '-=30' },{ duration: 1500 }); },300);//interval } kitemoving(); ,然后为将来的日期制作TypeName(varname)

尝试实施。

感谢您的帮助!

2 个答案:

答案 0 :(得分:1)

完成它。

使用beforeRender功能并停用将utcDateValue与当前日期进行比较的未来日期。

以下是代码:

$scope.beforeRender = function ($dates) {
    /* disable future dates */
    for(var i=0; i<$dates.length;i++) {
       if(new Date().getTime() < $dates[i].utcDateValue) {
          $dates[i].selectable = false;
       }
    }                
};

还添加了data-before-render="beforeRender($dates)"

<datetimepicker data-ng-model="user.join_date" data-datetimepicker-config="{ startView:'day', minView:'day' }" data-before-render="beforeRender($dates)" />

答案 1 :(得分:0)

仅允许未来

我需要一个稍微复杂一点的完全相反的要求,只允许将来需要考虑参数$ view

使用Javascript:

Sub Automate_Estimate()
Dim completed As Double

Set Wb = ThisWorkbook
Const steps = 9                                                            
'Number of rows copied



    MyFile = Application.GetOpenFilename(FileFilter:="Excel 
   Files,*.xl*;*.xm*")


    Set wkb = Workbooks.Open(MyFile, UpdateLinks:=0)

    completed = 0
    Application.StatusBar = "Copying In progress..."



        Call CopyRange(Sheets(SourceName).Range("C12:R12"), Wb.Sheets(DestName).Cells(1, 2), completed)
        completed = completed + (100 / steps)

        Call CopyRange(Sheets(SourceName).Range("C30:R30"), Wb.Sheets(DestName).Cells(24, 2), completed)
        completed = completed + (100 / steps)


        Call CopyRange(Sheets(SourceName).Range("C22:R22"), Wb.Sheets(DestName).Cells(4, 2), completed)
        completed = completed + (100 / steps)

        Call CopyRange(Sheets(SourceName).Range("C20:R20"), Wb.Sheets(DestName).Cells(14, 2), completed)
        completed = completed + (100 / steps)


        Call CopyRange(Sheets(SourceName).Range("C40:R40"), Wb.Sheets(DestName).Cells(17, 2), completed)
        completed = completed + (100 / steps)

        Call CopyRange(Sheets(SourceName).Range("C16:R16"), Wb.Sheets(DestName).Cells(7, 2), completed)
        completed = completed + (100 / steps)

        Call CopyRange(Sheets(SourceName).Range("C17:R17"), Wb.Sheets(DestName).Cells(8, 2), completed)
        completed = completed + (100 / steps)

        Call CopyRange(Sheets(SourceName).Range("C21:R21"), Wb.Sheets(DestName).Cells(16, 2), completed)
        completed = completed + (100 / steps)


        Call CopyRange(Sheets(SourceName).Range("C52:R52"), Wb.Sheets(DestName).Cells(56, 2), completed)
        completed = completed + (100 / steps)


        Application.StatusBar = False

        wkb.Close

    DoEvents
 End Sub

};

HTML:

$scope.futureOnlyBeforeRender = function($view, $dates) {
// $view values: year, month, day, hour, minute
var currentDate = new Date();
// set the current date according to the view
switch($view){
    case 'year': currentDate.setYear(currentDate.getYear() - 1); break;
    case 'month': currentDate.setMonth(currentDate.getMonth() - 1); break;
    case 'day': currentDate.setDate(currentDate.getDate() - 1); break;
    case 'hour': currentDate.setHours(currentDate.getHours() - 1); break;
    case 'minute': currentDate.setMinutes(currentDate.getMinutes() - 1); break;
}
// apply ot the dates
$dates.filter(function (date) {
    return date.utcDateValue < currentDate.getTime();
}).forEach(function (date) {
    date.selectable = false;
})
相关问题