2017-04-06 24 views
0

datepickerここからhttps://github.com/kekeh/mydatepicker/blob/master/README.mdを使用しています。今日までの日付を無効にする必要がありますので、現在の日と月を取得し、myDatePickerOptionsを渡す必要があります。新しいDate()関数を使用して、木2017年4月6日は、GMT + 0530(インド標準時)(次のように午後03時55分09秒になっとてもmyDatepickerOptionsどのように日の月と年を得ることができますか?私は、次のコードを試してみました。今日まで日付を日付ピッカーで無効にするにはどうすればよいですか?

import { Component, OnInit,ViewEncapsulation } from '@angular/core'; 
import { HeaderComponent } from '../header/header.component'; 
import {IMyOptions, IMyDateModel,IMyDate} from 'mydatepicker'; 
import { TimepickerConfig } from 'ng2-bootstrap/timepicker'; 
import { FormGroup,FormControl,Validators } from '@angular/forms'; 

@Component({ 
    selector: 'app-createsession', 
    templateUrl: './createsession.component.html', 
    styleUrls: ['./createsession.component.css'], 
    encapsulation: ViewEncapsulation.None 
}) 
export class CreatesessionComponent implements OnInit { 

    eventform : FormGroup ; 

    public mytime: Date = new Date(); 

    private myDatePickerOptions: IMyOptions = { 
     // need use the current day,month and year 

     disableUntil: {year: 2016, month: 8, day: 10}, 
     dateFormat: 'dd.mm.yyyy' 
    }; 
    constructor() { } 

    ngOnInit() { 
    console.log(this.mytime); 

    }); 

    } 
    onDateChanged(event: IMyDateModel) { 
     // event properties are: event.date, event.jsdate, event.formatted and event.epoc 
    } 




onSubmit(){ 
    console.log(this.eventform.value); 
} 
} 

答えて

1
それを使用することはできません

現在の日付から日付、年、および月を抽出し、それをdisableUntilプロパティに設定します。

public mytime: Date = new Date(); 

currentYear: any = this.mytime.getUTCFullYear(); 
currentDate: any = this.mytime.getUTCDate(); 
currentMonth: any = this.mytime.getUTCMonth() + 1; //months from 1-12 

private myDatePickerOptions: IMyOptions = { 
    // need use the current day,month and year 

    disableUntil: {year: this.currentYear, month: this.currentMonth, day: this.currentDate}, 
    dateFormat: 'dd.mm.yyyy' 
}; 
+0

ngOnInit()メソッドでcurrentyear、currentdate、およびmonthを設定しますか? –

+0

mytimeのすぐ下に置くことができます。私の更新された答えを見つけてください。 – Vikash

関連する問題