3

我正在使用 Angular2 和 Semantic-UI 的分叉版本(包括日历模块)。我正在使用calendardropdown功能:

constructor() {
    setTimeout(() => {
        jQuery('.ui.dropdown').dropdown();
        jQuery('.ui.calendar').calendar({ type: 'date' });
    }, 1000);)
}

这是我的 Plunker

如您所见,我无法从日历选择中获取输入。

我不明白可能是什么故障。你能弄清楚可能是什么问题吗?

4

1 回答 1

3

由于某些未知原因[(ngModel)]没有得到更新。

但如果只是获取日期的问题,您可以使用#templateVariable,如此处所示。

工作演示:https ://plnkr.co/edit/X8Gjwzd62DvYN1S8jrFv?p=preview

使用#TemplateVariable

<input #date  type="text" placeholder="Date">

<button (click)="test(date.value)">test</button> 

test(date):void { 
    console.log(date);
    console.log(this.name);
}

使用@ViewChild

@ViewChild('date') date:ElementRef;

 test(date):void { 
       console.log(this.date.nativeElement.value);
        console.log(date);
        console.log(this.name);
 }
于 2016-10-05T14:58:31.097 回答