![](/img/trans.png)
[英]How do I ensure a select change event fires AFTER ngmodel is set in Angular2?
[英]Angular2 ngModel undefined with <input> tag
我正在使用Angular2和Semantic-UI的分叉版本(包括日歷模塊)。 我正在使用calendar
和dropdown
功能:
constructor() {
setTimeout(() => {
jQuery('.ui.dropdown').dropdown();
jQuery('.ui.calendar').calendar({ type: 'date' });
}, 1000);)
}
這是我的Plunker 。
如您所見,我無法從日歷選擇中獲得輸入。
我無法理解可能是什么故障。 你能弄明白可能是什么問題嗎?
由於某些未知原因[(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);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.