ng2-datepicker不起作用

时间:2017-03-03 13:47:59

标签: angular datepicker webpack datetimepicker

我正在尝试将datepicker用于我的角度2应用,但是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>

我没有收到任何错误,但是日期选择器没有显示。

有人可以为angular 2 webpack项目建议datepicker模块吗?

2 个答案:

答案 0 :(得分:0)

如果查看ng-datepicker的源代码,您会看到它导出一个名为DatepickerOptions的接口(只有两个大写字母,而不是三个)。我认为这是个问题。

答案 1 :(得分:0)

尝试使用z-index属性将其显示在顶部。

.ngx-datepicker-container[_ngcontent-c8] .ngx-datepicker-calendar- 
 container[_ngcontent-c8] {
 z-index: 999 !important;
 width: 100% !important;
}
相关问题