Angular2/NativeScript:DatePicker不';根本不显示,Nativescript日期选择器文档几乎不存在
我正忙于Angular2/Nativescript应用程序,在输入日期时遇到了一些问题。。。我试图使用DatePicker组件,但由于某些原因,在视图上应该显示日期选择器的位置不会呈现任何内容。我通读了(非常有限的)Nativescript DatePicker文档,但不幸的是,它们没有包含任何xml示例。。。你知道为什么我的约会对象没来吗?我觉得自己被卡住了,觉得很奇怪Nativescript DatePicker页面上的信息太少了 我的视图代码:Angular2/NativeScript:DatePicker不';根本不显示,Nativescript日期选择器文档几乎不存在,angular,nativescript,angular2-nativescript,Angular,Nativescript,Angular2 Nativescript,我正忙于Angular2/Nativescript应用程序,在输入日期时遇到了一些问题。。。我试图使用DatePicker组件,但由于某些原因,在视图上应该显示日期选择器的位置不会呈现任何内容。我通读了(非常有限的)Nativescript DatePicker文档,但不幸的是,它们没有包含任何xml示例。。。你知道为什么我的约会对象没来吗?我觉得自己被卡住了,觉得很奇怪Nativescript DatePicker页面上的信息太少了 我的视图代码: <StackLayout class=
<StackLayout class="page">
<StackLayout *ngIf="!invoiceInProgress && !captureInProgress">
<StackLayout class="form">
<stackLayout class="input-field">
<TextField class="input input-border" hint="Enter Order Number" [(ngModel)]="orderNumber"></TextField>
</stackLayout>
<Button class="btn btn-primary" text="Verify Order Number" (tap)="verifyOrderNumber()" [isEnabled]="orderNumber !== '' && orderNumber != null"></Button>
</StackLayout>
</StackLayout>
<StackLayout *ngIf="invoiceInProgress">
<Label class="h1 title m-x-auto" text="Invoice details"></Label>
<StackLayout class="form">
<StackLayout class="input-field">
<TextField class="input input-border" hint="Enter Invoice Number"></TextField>
</StackLayout>
</StackLayout>
<DatePicker #invoiceDatePicker [(ngModel)]="invoiceDate"></DatePicker>
</StackLayout>
</StackLayout>
and in my controller:
invoiceDate: Date = new Date("2017/01/01");
在我的控制器中:
发票日期:日期=新日期(“2017/01/01”);
根据文档中的说明,您可以使用nativeScript loaded事件并如下设置日期选择器属性
HTML文件
工作日期选择器和列表选择器的完整示例可以在中找到。我已经在我的Nativescript Angular2应用程序中实现了生日选择器。我不确定它是否能帮助您解决问题,但您可以参考我的代码 HTML
<TextView class="input" id="birthday" [(ngModel)]="userDetail.birthday" hint="Enter date" [text]="birthDate | amDateFormat:'LL'" (tap)="showDatePicker()" returnKeyType="done" (returnPress)="submit()" row="0" col="1" style.horizontalAlignment="left" width="70%" marginLeft="-5"></TextView>
TS
export class EditProfileComponent{
public birthDate;
ngOnInit() {
let datePicker = this.page.getViewById<DatePicker>("datePicker");
datePicker.year = 1980;
datePicker.month = 2;
datePicker.day = 9;
datePicker.minDate = new Date(1975, 0, 29);
datePicker.maxDate = new Date(2045, 4, 12);
}
enterDate() {
let datePicker = this.page.getViewById<DatePicker>("datePicker");
let selectedDate = new Date(datePicker.year, datePicker.month - 1, datePicker.day);
this.birthDate = selectedDate;
this.isButtonVisible = false;
this.isItemVisible = false;
}
showDatePicker() {
let textFielsBDate = this.page.getViewById<TextView>("birthday");
this.isButtonVisible = true;
this.isItemVisible = true;
}
}
导出类EditProfileComponent{
公众出生日期;
恩戈尼尼特(){
让datePicker=this.page.getViewById(“datePicker”);
datePicker.year=1980;
datePicker.month=2;
datePicker.day=9;
datePicker.minDate=新日期(1975,0,29);
datePicker.maxDate=新日期(2045,4,12);
}
输入日期(){
让datePicker=this.page.getViewById(“datePicker”);
让selectedDate=新日期(datePicker.year,datePicker.month-1,datePicker.day);
this.birthDate=所选日期;
this.isButtonVisible=false;
this.isItemVisible=false;
}
showDatePicker(){
让textFielsBDate=this.page.getViewById(“生日”);
this.isButtonVisible=true;
this.isItemVisible=true;
}
}
您是否确保正在显示stacklayout?带有*ngIf=“invoiceInProgress”
的一个正在显示。。。请删除此答案。在未来,我认为你应该在添加评论部分添加问题…我建议使用datePicker插件:我已经尝试过angular,它的工作很好,可以用vanila说很多,但这里是如何使用angular@Dlucidone完成的,谢谢你看一看,我尝试过一开始就这么做,但没有运气。。。我刚刚复制/粘贴了您的代码,但仍然没有更改。我把它放在几个文本字段的中间,上面显示了DeDePikor上面的文本字段,但是下面的所有内容现在都不见了…我正在使用核心黑暗主题,如果这有什么不同。。。
<TextView class="input" id="birthday" [(ngModel)]="userDetail.birthday" hint="Enter date" [text]="birthDate | amDateFormat:'LL'" (tap)="showDatePicker()" returnKeyType="done" (returnPress)="submit()" row="0" col="1" style.horizontalAlignment="left" width="70%" marginLeft="-5"></TextView>
export class EditProfileComponent{
public birthDate;
ngOnInit() {
let datePicker = this.page.getViewById<DatePicker>("datePicker");
datePicker.year = 1980;
datePicker.month = 2;
datePicker.day = 9;
datePicker.minDate = new Date(1975, 0, 29);
datePicker.maxDate = new Date(2045, 4, 12);
}
enterDate() {
let datePicker = this.page.getViewById<DatePicker>("datePicker");
let selectedDate = new Date(datePicker.year, datePicker.month - 1, datePicker.day);
this.birthDate = selectedDate;
this.isButtonVisible = false;
this.isItemVisible = false;
}
showDatePicker() {
let textFielsBDate = this.page.getViewById<TextView>("birthday");
this.isButtonVisible = true;
this.isItemVisible = true;
}
}