【问题标题】:angular datepicker is not working角度日期选择器不工作
【发布时间】:2018-01-24 10:27:19
【问题描述】:

angular4-datepicker

它给出的错误如下:

错误 TS2307:找不到模块“mydatepicker”

这里也给出编译时错误:

从 'mydatepicker' 导入 { MyDatePickerModule };

report.module.ts:

import { FormsModule } from '@angular/forms';
import { MyDatePickerModule } from 'mydatepicker';
@NgModule({
  imports: [  
    MyDatePickerModule,
    FormsModule
  ] 
})

report.component.ts:

import {IMyDpOptions} from 'mydatepicker';
@Component({
  selector: 'app-report',
  templateUrl: './report.component.html',
  styleUrls: ['./report.component.css']
})
export class ReportComponent implements OnInit { 

  public myDatePickerOptions: IMyDpOptions = {
    // other options...
    dateFormat: 'dd.mm.yyyy',
};
}

report.component.html:

 <my-date-picker name="mydate" [options]="myDatePickerOptions" [(ngModel)]="filterData.firstDate" required></my-date-picker>

我用:

角度:5.2.1 角 CLI:1.6.5

【问题讨论】:

  • 发布你的代码module.ts和组件代码
  • 你使用的是材料设计还是范式?
  • 我使用普通形式。
  • 显示你的模板

标签: javascript angular npm datepicker


【解决方案1】:

请使用npm install mydatepicker --save 而不是npm install angular4-datepicker --save

它对我有用。

谢谢

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-09-13
    • 2020-11-13
    • 2014-07-21
    • 1970-01-01
    • 2021-02-13
    相关资源
    最近更新 更多