Select Angular2 ngModel未定义,带有<;输入>;标签
我正在使用Angular2和一个分叉版本的语义UI(包括日历模块)。我正在使用Select Angular2 ngModel未定义,带有<;输入>;标签,select,angular,calendar,semantic-ui,angular2-ngmodel,Select,Angular,Calendar,Semantic Ui,Angular2 Ngmodel,我正在使用Angular2和一个分叉版本的语义UI(包括日历模块)。我正在使用日历和下拉列表功能: constructor() { setTimeout(() => { jQuery('.ui.dropdown').dropdown(); jQuery('.ui.calendar').calendar({ type: 'date' }); }, 1000);) } 这是 如您所见,我无法从日历选择中获取输入 我不明白什么是小故障。你能找出问
日历
和下拉列表
功能:
constructor() {
setTimeout(() => {
jQuery('.ui.dropdown').dropdown();
jQuery('.ui.calendar').calendar({ type: 'date' });
}, 1000);)
}
这是
如您所见,我无法从日历选择中获取输入
我不明白什么是小故障。你能找出问题出在哪里吗?由于某种未知原因,[(ngModel)]没有得到更新 但是,如果只是获取日期的问题,您可以使用#templateVariable,如下所示 工作演示: 使用模板变量
<input #date type="text" placeholder="Date">
<button (click)="test(date.value)">test</button>
test(date):void {
console.log(date);
console.log(this.name);
}
你试过Angular2的更新版本吗?Beta 0已经很老了。有没有办法不在
test
函数中传递templateVariable而使其工作?我的真实代码中没有测试按钮。我使用ViewChild更新了我的plunker以访问ts代码中的数据。非常感谢您的回复。由于我使用的是ReactiveFormsModule
能否请您使用formControl
而不是ngModel
对表单的每个元素(日历和选择)更新您的代码。无论如何,在我的项目中使用您的代码会破坏一些东西:GEThttp://localhost:3000/user/traceur 404(未找到)
@ViewChild('date') date:ElementRef;
test(date):void {
console.log(this.date.nativeElement.value);
console.log(date);
console.log(this.name);
}