我正在尝试为我的angular 2应用程序使用datepicker,但ng2-datepicker不起作用
我已经使用npm安装了ng2-datepicker:
npm install ng2-datepicker --save
然后在app.modules.ts文件中导入DatePickerModule:
import { DatePickerModule } from 'ng2-datepicker';
然后:
import { DatePickerOptions, DateModel } from 'ng2-datepicker';
@Component({
templateUrl: 'register.component.html'
})
export class RegisterComponent implements OnInit {
model: any = {};
datePickerOptions: DatePickerOptions;
date:DateModel;
constructor() {
this.datePickerOptions = new DatePickerOptions();
}
}HTML:
<ng2-datepicker [options]="datePickerOptions" name="date" [(ngModel)]="date"></ng2-datepicker>我没有收到任何错误,但是datepicker没有显示。
有没有人能为angular 2的项目推荐datepicker模块?
发布于 2017-12-29 05:38:25
如果您查看ng-datepicker的源代码,您将看到它导出了一个名为DatepickerOptions的接口(只有两个大写字母,而不是三个)。我相信这就是问题所在。
发布于 2018-04-08 14:14:05
尝试使用z-index属性将其显示在顶部。
.ngx-datepicker-container[_ngcontent-c8] .ngx-datepicker-calendar-
container[_ngcontent-c8] {
z-index: 999 !important;
width: 100% !important;
}https://stackoverflow.com/questions/42580619
复制相似问题